6027专题

HDU - 6027 Easy Summation

题意: f(i)=ik f ( i ) = i k f(i) = i^k sum=f(1)+f(2)+f(3)⋅⋅⋅⋅⋅⋅f(n) s u m = f ( 1 ) + f ( 2 ) + f ( 3 ) · · · · · · f ( n ) sum =f(1) + f(2) + f(3) ······f(n) 给你两个数n,k,求sum。对mod取余。 求幂嘛,,,上来就是快

LeetCode 6027. 统计数组中峰和谷的数量

题目链接: 力扣https://leetcode-cn.com/problems/count-hills-and-valleys-in-an-array/ 【分析】先遍历一遍在原数组上去重,然后根据要求找就行了。 class Solution {public int countHillValley(int[] nums) {int n = nums.length;int i, m = 1