23 1 1 2
Case #1: 1 22
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; #define ll long long #define CL(a) memset(a,0,sizeof(a)) ll C,k1,b1,k2; ll a,b; ll mod_pow(ll x, ll y, ll mod) { ll re=1; while (y) { if (y&1) re=re*x%C; x=x*x%C; y>>=1; } return re; } int main () { int cas=1; while (cin>>C>>k1>>b1>>k2) { cout<<"Case #"<<cas++<<":"<<endl; bool flag=false; for (a=1; a<C; a++) { b = C-mod_pow(a, k1+b1, C); if ((mod_pow(a,k1,C)*(C-b)%C+mod_pow(b,k2,C)*b%C)%C==0) cout<<a<<" "<<b<<endl,flag=true; } if (!flag) cout<<"-1"<<endl; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/d_x_d/article/details/49029637