题解:所有计算都是对n取模的,不妨设F(i) = f(i) mod n。不难发现,当二元组(F(i),F(i+1))出现重复时,整个序列就开始重复。因为余数最多 n种,所以最多n2 项就会出现重复。设周期为M,则只需要计算出F[0]~F[n2],然后算出F[ab]等于其中哪一项就可以了。 摘自《算法 ...
分类:
其他好文 时间:
2017-08-15 10:11:49
阅读次数:
127
由于编辑器总是崩溃,我只能直接把代码贴上了。 ...
分类:
其他好文 时间:
2017-08-14 11:32:09
阅读次数:
236
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3306 题目意思:一个斐波那契数列的变式,本来是A[n]=A[n-1]+A[n-2],现在变成A[n]=N*A[n-1]+Y*A[n-2]。一个很简单的矩阵快速幂。 S(N) = A(0)2 +A(1)2 ...
分类:
其他好文 时间:
2017-08-13 10:11:04
阅读次数:
164
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2855 题目意思:求一个式子g[n]=∑C(n,k)*f[k],n很大,很明显是一个矩阵快速幂。可以打表发现g[n]=f[2*n]划开可以发现g[n]=3*g[n-1]-f[n-2]。 思路:我们现在可以 ...
分类:
其他好文 时间:
2017-08-13 10:06:41
阅读次数:
155
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9296 Accepted Submissio ...
分类:
其他好文 时间:
2017-08-11 15:58:52
阅读次数:
176
Happy Number UVA - 10591 Let the sum of the square of the digits of a positive integer S0 be represented by S1. In a similar way, let the sum of the s ...
分类:
移动开发 时间:
2017-08-10 17:04:00
阅读次数:
240
This method passes a constant literal String of length 1 as a parameter to a method, that exposes a similar method that takes a char. It is simpler an ...
分类:
其他好文 时间:
2017-08-09 21:05:25
阅读次数:
3036
2017 8 9 得分:70 感觉现在自己最弱的地方不是在于思维活性上,而是在于那些本不应该出现在我身上的问题,比如说什么看出正解打不出来啦、打出正解莫名其妙被卡分啦、莫名其妙少些什么导致爆零啦、读不懂题啦、读不懂题啦、读不懂题啦……反正问题太多了…… A、calc 题意:求出所有顺序对的贡献,定义 ...
分类:
其他好文 时间:
2017-08-09 20:10:29
阅读次数:
230
https://vjudge.net/problem/UVA-11582 题意:求 斐波那契数列第a^b 项 %n的余数 a,b < 2^64,n<1000 找循环节,最多n^2项一定会出现循环节 ...
分类:
其他好文 时间:
2017-08-09 10:14:36
阅读次数:
113
Largest Submatrix http://acm.hdu.edu.cn/showproblem.php?pid=2870 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Prob ...
分类:
其他好文 时间:
2017-08-08 21:41:34
阅读次数:
183