#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namespace std; typedef long long LL; const LL INF = 0xffffff; const LL maxn = 100005; const LL MOD = 1e9+7; LL C, k1, k2, b1; LL QuickPow(LL a, LL k, LL mod) { LL ans = 1, P = a; while( k ) { if(k%2 == 1) ans = (ans * P)%mod; k /= 2; P = (P * P)%mod; } return ans; } int main() { LL ans = 0, a, b; int cas = 1; while(cin >> C >> k1 >> b1 >> k2) { ans = 0; printf("Case #%d:\n", cas ++); for(int i=1; i<C; i++)///枚举a { a = i; b = C - QuickPow(a, k1+b1, C); if( (QuickPow(a, 2*k1+b1, C) + QuickPow(b, k2+1, C))%C == 0 ) { printf("%I64d %I64d\n", a, b); ans ++; } } if(ans == 0) printf("-1\n"); } return 0; }
HDU 5478 Can you find it(数学问题)
原文:http://www.cnblogs.com/chenchengxun/p/4844740.html