标签:
Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 450 Accepted Submission(s): 208
#include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> using namespace std; #define N 1234567 #define M 12 int c, k1, b1, k2; bool flag; int quickpow(int m,int n,int k)// m^n % k { int b = 1; while (n > 0) { if (n & 1) b = (b*m)%k; n = n >> 1 ; m = (m*m)%k; } return b; } int main() { int tt = 1; int b; while(~scanf("%d %d %d %d", &c, &k1, &b1, &k2)) { printf("Case #%d:\n", tt++); flag = 0; for(int a = 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; }
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4842040.html