题目:http://acm.hdu.edu.cn/showproblem.php?pid=1098
f(x)=5*x^13+13*x^5+k*a*x,似的任意的x,使得65/f(x)为整数。给出k,找到最小的a。
思路:
因为x是任意的,所以取x为1,f(1)=18+k*a,(18+k*a)%65==0,a肯定不能一直取下去,把模运算分配律一下,
(a+b)%c==(a%c+b%c)%c,原式(18+k*a%65)%65,a超过65都是重复。
#include<iostream>
using namespace std;
int main()
{
int k,a;
while (cin >> k)
{
for (a = 1; a <= 65; a++)
if ((18 + k*a) % 65 == 0)
break;
if (a > 65)
cout << "no\n";
else
cout << a << endl;
}
return 0;
}