HDU 1098 Ignatius's puzzle

Ignatius's puzzle

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2737 Accepted Submission(s): 1805


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

11
100
9999

Sample Output

22
no
43

Author

eddy
 
数学归纳法证明! 最后只要证明 18 + k * x 能整除65就可以了。
 
 1 #include<stdio.h>
2 int main ()
3 {
4 int k , i ;
5 while ( scanf ( "%d" , &k ) != EOF )
6 {
7 if ( k % 65 == 0 )
8 {
9 printf ( "no\n" ) ;
10 continue ;
11 }
12 for ( i = 1 ; i <= 65 ; ++ i )
13 {
14 if ( ( 18 + k * i ) % 65 == 0 )
15 {
16 printf ( "%d\n" , i ) ;
17 break ;
18 }
19 }
20 if ( i > 65 )
21 printf ( "no\n" ) ;
22 }
23 return 0 ;
24 }

  

posted @ 2011-08-05 18:27  贺佐安  阅读(282)  评论(0)    收藏  举报