hdu 1098 Ignatius's puzz
有关数论方面的题要仔细阅读,分析公式。
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".
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
11
100
9999
、
Sample Output
22 no 43
Author
eddy
题目大意:方程f(x)=5*x^13+13*x^5+k*a*x;输入任意一个数k,是否存在一个数a,对任意x都能使得f(x)能被65整出;输入a;
解题报告:假设存在这个数a ,因为对于任意x方程都成立,所以,当x=1时f(x)=18+ka;有因为f(x)能被65整出,这可得出f(x)=n*65;
即:18+ka=n*65;若该方程有整数解则说明假设成立。
所以,只要找到a,使得18+k*a能被65整除,也就解决了这个题目.
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int k,i; 6 while(scanf("%d",&k)!=EOF) 7 { 8 for(i=1;i<=10000;i++) 9 { 10 if((18+k*i)%65==0){printf("%d\n",i);break;} 11 } 12 if(i>10000)printf("no\n"); 13 } 14 return 0; 15 }