Title Link: http://vjudge.net/problem/HDU-1098
Solution Ideas:
F (x) =5*x^13+13*x^5+k*a*x;
In the title "F (x) |65" means that any integer x,f (x) can be divisible by 65. So it is not difficult to infer: f (x+1) |65 is also established.
F (x+1) =5* (x+1) ^13+13* (x+1) ^5+k*a* (x+1),
According to the two-term theorem: (a+b) ^n=c (n,0) a^n+c (n,1) a^ (n-1) *b+c (n,2) a^ (n-2) *b^2+...+c (n,n) b^n
To: F (x+1) =5* (c (13,0) +c (13,1) *x+c (13,2) *x^2+...+c (13,13) *x^13) + 13* (c (5,0) +c (5,1) *x+...+c (5,5) *x^5) + k*a* (x+1);
After extracting F (x) from it:
F (x+1) =f (x) +5* (c (13,0) + C (13,1) *x+c (13,2) *x^2+...+c (13,12) *x^12) + 13* (c (5,0) +c (5,1) *x+...+c (5,4) *x^4) + k*a;
It is not difficult to see the 5*c (13,0), 13*c (5,0) and K*a three, other items regardless of x take any integer can be divisible by 65, so if 5*c (13,0) +13*c (5,0) +k*a (equivalent to 18+k*a) can be divisible by 65, you can draw F (x+1 ) |65.
Verify that f (1) =5+13+k*a=18+k*a is also applicable.
So the final problem is given a nonnegative integer k, which causes (18+k*a) |65 to output the smallest nonnegative integer A that satisfies this condition.
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 6 intMain ()7 {8 intK,a;9 while(cin>>k)Ten { One if(k% $==0) A { -printf"no\n"); - Continue; the } - for(a=0;a< $;++a) - { - if((a*k)% $== -) + { -printf"%d\n", a); + Break; A } at } - if(a== $) printf ("no\n"); - } - - return 0; -}
View Code
(HDU) 1098--Ignatius's puzzle (the confusion of Ignatius)