|
Ignatius's puzzleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6372 Accepted Submission(s): 4414
Problem Description
Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5*x^13+13*x^5+k*a*x,input a nonegative integer k(k<10000),to find the minimal nonegative integer a,make the arbitrary integer x ,65|f(x)if
no exists that a,then print "no".
Input
The input contains several test cases. Each test case consists of a nonegative integer k, More details in the Sample Input.
Output
The output contains a string "no",if you can't find a,or you should output a line contains the a.More details in the Sample Output.
Sample Input
Sample Output
我的AC代码:
以下是网上了解到的两种解题说法,顺便记录以便日后深入理解。
一、数学归纳法 f(x)=5*x^13+13*x^5+k*a*x 假设当x=n时 65|f(x)成立,那一定有 65|f(n+1)成立 那么65|f(n+1)-f(n) 成立 通过二项展开可以得到只要18+k*a可以被65整除就可以了 在0~64之间遍历就ok。
其程序例子如下:
二、
f(x)=5*x^13+13*x^5+k*a*x=x(5*x^12+13*x^4+k*a),这个函数的形式直接就是费马小定理的形式
费马小定理是数论中的一个重要定理,其内容为: 假如p是质
数, 且(a,p)=1,那么 a^(p-1) ≡1(mod p) 假如p是质数,且a,p互质,那么 a的(p-1)次方除以p的余数恒等于1
对f(x)=x(5*x^12+13*x^4+k*a)用此定理分析:
(1)如果x是65的倍数,那么已经符合65整除f(x)
|
杭电 acm 1098
最新推荐文章于 2019-12-09 11:11:00 发布