题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3240 n 和 m 太过巨大,不难想到应该用费马小定理什么的来缩小范围: 总之就是推式子啦,看博客:https://blog.csdn.net/jiangshibiao/article/details/24594825 还有:https://www.cnblogs.com/iiyiyi/p/5617598.html 其实也蛮好推的,也挺好写,但我调了很久很久啊... 要十分注意取 mod 时…
MF( i ) = a ^ fib( i-1 ) * b ^ fib ( i ) ( i>=3) mod 1000000007 是质数 , 依据费马小定理 a^phi( p ) = 1 ( mod p ) 这里 p 为质数 且 a 比 p小 所以 a^( p - 1 ) = 1 ( mod p ) 所以对非常大的指数能够化简 a ^ k % p == a ^ ( k %(p-1) ) % p 用矩阵高速幂求fib数后代入就可以 M斐波那契数列 Time Limit: 3000/100…
M斐波那契数列 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 43 Accepted Submission(s) : 28 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description M斐波那契数列F[n]是一种整数数列,它的定义如下: F[…
题目链接: Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description Holion August will eat every thing he has found. Now there are many foods,but he does not want to eat all of them at once,so he fi…
首先假设输入的是n,m 我们就是要求m^(Σ(c(n,i) i|n)) mod p 那么根据费马小定理,上式等于 m^(Σ(c(n,i) i|n) mod (p-1)) mod p 那么问题的关键就是求 Σ(c(n,i) i|n) mod (p-1)了 那么如果P是素数的话,我们可以用lucas定理来快速求出来组合数,这道题的p-1是 非素数,那么我们分解质因数pi,假设c(n,i) i|n为X,那我们求出来X mod pi=ai,这个是 符合lucas定理的,那么我们可以得到质因子数个式子…
Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1424 Accepted Submission(s): 469 Problem Description Holion August will eat every thing he has found. Now there are many foods,bu…