HDUOJ-----1098 Ignatius's puzzle

Ignatius's puzzle

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

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
 
 
 
 
 
 
 
 
 
 
这道题,如果能够在高中的时候,很定能够求出来的..
 
  对于           F(x)=5*x^13+13*x^5+k*a*x;
  数学归纳如下:
                              当x=1时,F(1)=5+13+k*a (此时需要找一个a使得,条件成立)。
                           假设  当x=k时,其成立;
                             当.x=k+1时,也应当成立。但实际上5*(x+1)^13+13*(x+1)^5+k*a*(x+1);
                     展开之后                 0                     13 
                                           5*(C  *x^13.........C *x^0)+13*(.....同前头.....)+k*a*x + k*a ;
                                                       13                    13                  
             最后我5*x^13+13*x^5+kax +5+13+ka  +后面部分(由于是65的倍数,就不讲啦)....由于当x=xs十,条件是成立的....所以最后只需要将(13+5+ka)%65
            等于0就行了!!而a必须小于65,不然就没有意义了!!试想a如果是65的倍数的话....那么F(x+1)处,便放到后头省掉了...
由此就不难写出代码了!!
代码如下:
                 
 1 #include<iostream>
 2 using namespace std;
 3 int main( void )
 4 {
 5     int k,a;
 6     while(cin>>k)
 7     {
 8         a=0;
 9       for(int i=1;i<65;i++)
10       {
11           if((18+i*k)%65==0)
12           {  a=i;
13              break;
14           }
15       }
16       if(a)cout<<a<<endl;
17       else cout<<"no"<<endl;
18        
19     }
20     return 0;
21 }
View Code

 

 
posted @ 2013-07-24 20:09  龚细军  阅读(405)  评论(0编辑  收藏  举报