Can you find it
Time limit:8000/5000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): Accepted submission (s): 208
Problem Descriptiongiven a prime numberC(1≤C≤x10) , and three integers K1, B1, K2(1≤K1,K2,B1≤10) . Please find all pairs (A, B) which satisfied the equationAk⋅ Nb1 +Bk⋅ Nk+1 = 0 (mod C) (n = 1, 2, 3, ...).
Inputthere is multiple test cases (no more than 30). For each test, a single line contains four integers C, K1, B1, K2.
Outputfirst, please output ' case #k: ', K is the number in test case. See sample output for more detail.
Please output the pairs (A, B) in lexicographical order. (1a,b<c. If There is not a pair (a, b), please output-1.
Sample Input23 1 1 2
Sample outputcase #1:1 22
Source ACM/ICPC Asia Regional Shanghai Online
Recommendhujie first wants N to be ... Must be set up, so first ensure that n=1 set up, and then verify that the other is established, the equation to the left of the B that one to the right, except for a moment, found that each increment is a^k1 and b^k2 so long as the n=2 set up, the back of the establishment. Don't be afraid of the problem next, or you can do it.
#include <queue>#include<math.h>#include<stdio.h>#include<string.h>#include<string>#include<iostream>#include<algorithm>using namespacestd;#defineN 1234567#defineM 12intC, K1, B1, K2;BOOLFlag;intQuickpow (intMintNintK//m^n% k{ intb =1; while(N >0) { if(N &1) b= (b*m)%K; N= N >>1 ; M= (m*m)%K; } returnb;}intMain () {inttt =1;intb; while(~SCANF ("%d %d%d%d", &c, &k1, &B1, &K2)) {printf ("Case #%d:\n", tt++); Flag=0; for(intA =1; a < C; a++) {b= C-quickpow (a,k1+b1,c); if(Quickpow (A, k1*2+B1, C) + Quickpow (b, k2*2-k2+1, c))%c = =0) {printf ("%d%d\n", A, b); Flag=1; } } if(Flag = =0) printf ("-1\n"); } return 0;}
HDU 5478 Can you find it