c语言sscanf函数的用法是什么
248
2022-08-31
BestCoder Round #64 (div.2) 1002 and 1003
Sum
Description
There is a number sequenceA1,A2....An,you can select a interval [l,r] or not,all the numbers Ai(l≤i≤r) will become f(Ai).f(x)=(1890x+143)mod10007.After that,the sum of n numbers should be as much as possible.What is the maximum sum?
Input
There are multiple test cases. First line of each case contains a single integer n.(1≤n≤105) Next line contains n integers A1,A2....An.(0≤Ai≤104) It's guaranteed that ∑n≤106.
Output
For each test case,output the answer in a line.
Sample Input
2 10000 9999 5 1 9999 1 9999 1
Sample Output
19999 22033
分析:原数组之和加上增量数组的最大连续子区间之和
#include Arrayis a magician who loves math. She has great power in copying and creating.One day she gets an array {1}。 After that, every day she copies all the numbers in the arrays she has, and puts them into the tail of the array, with a signle '0' to separat.Vicky wants to make difference. So every number which is made today (include the 0) will be plused by one.Vicky wonders after 100 days, what is the sum of the first M numbers.InputThere are multiple test cases.First line contains a single integer T, means the number of test cases.(1≤T≤2∗103)Next T line contains, each line contains one interger M. (1≤M≤1016)OutputFor each test case,output the answer in a line.Sample Input3135Sample Output147 学好递归是很有必要的! 0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5…… 红色区域第四层: 数字:1 2 3 4 个数:1 3 3 1 第五层: 数字:1 2 3 4 5 个数:1 4 6 4 1 数字个数和杨辉三角相关,前N+1层数字一共有个,10^16小于1<<50,那么用递归的话while循环求出各层数字和加上递归调用最坏结果:50+X*50 可以满足时间限制。 #include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~