- 博客(8)
- 收藏
- 关注
原创 hdoj1013:Digital Roots
题目: The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the pro
2021-09-06 21:08:18 74
原创 hdoj1014:Uniform Generator
题目: Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form seed(x+1) = [seed(x) + STEP] % MOD where ‘%’ is the modulus operator. Such a function will generate pseudo-random numbers (seed)
2021-09-06 20:33:12 84
原创 hdoj1009:FatMouse‘ Trade
题目: FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMou
2021-09-06 20:24:24 68
原创 hdoj1008:Elevator
题目: The three hands of the clock are rotating every second and meeting each other many times everyday. Finally, they get bored of this and each of them would like to stay away from the other two. A hand is happy if it is at least D degrees from any of the
2021-09-06 19:46:51 57
原创 hdoj1012:u Calculate e
题目: A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n. 分析: 简单的阶乘求解。 三层循环,第一层循环n从0到9,第二层循环求和项的个数,第三层循环求阶乘。 本题的问题主要是0 1 2时输出形式不同,3-9时统一是9
2021-09-05 22:14:49 67
原创 hdoj1005:Number Sequence
题目: A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). 分析: 直接递归会Memory Limit Exceeded 找规律,可以发现最后结果是mod7,而且只与f(n-1)和f(n-2)有关,可以得出有循环规律,至少49个元素
2021-09-05 17:06:16 58
原创 hdoj1004:Let the Balloon Rise
题目: For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case. 分析: 用balloon存储颜色,用count存储每个颜色出现的次数。 每输入一个新颜色,判断它是否出现过。如果出现过,将其count值加1并把flag置为1表示出现过。如果没有出现过
2021-09-05 16:30:34 90
原创 hdoj1003:Max Sum
题目: Given a sequence a[1],a[2],a[3]…a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. 分析: 求解最大和子序列。 用sum记录和,当sum值小于0时,重新更新start值。 当sum值大于当前记录的maxsum值时,更新
2021-09-05 15:57:50 47
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人