`
jinvasshole
  • 浏览: 770107 次
文章分类
社区版块
存档分类
最新评论

HDU 3307 Description has only two Sentences 数论

 
阅读更多

Description has only two Sentences

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 199Accepted Submission(s): 9
Problem Description
an= X*an-1+ Y and Y mod (X-1) = 0.
Your task is to calculate the smallest positive integer k that akmod a0= 0.
Input
Each line will contain only three integers X, Y, a0( 1 < X < 231, 0 <= Y < 263, 0 < a0< 231).
Output
For each case, output the answer in one line, if there is no such k, output "Impossible!".
SampleInput
2 0 9
SampleOutput
1

(x^k-1)*(y/(x-1))=0(mod a0),再将(y/(x-1))和a0先消掉公因数,就是要求最小k满足x^k=1(mod m)

k^euler(m)=1(modm),找euler(m)的因数中能满足k^x=1(mod m)的最小x(快速幂)
循环节:a^b=a^(b+t) (mod c) -> a^t=1(mod c) -> 满足a^x=1(mod c) 则 x=t*k;(抽屉原理)
euler: a^euler=1(mod c)

好像也可以用什么离散对数做,反正我不知道那东东
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics