【題目連結】click here~~
【題目大意】;
【思路】:一早起來突然想到隻要判斷1,2是否符合就可以了,那麼此題就是一個暴力題了,卡常數,呀。卡常數!!
/*
* Problem: HDU No.5478
* Running time: 3600MS
* Complier: G++
* Author: javaherongwei
* Create Time: 17:24 2015/9/26 星期六
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
typedef long long LL;
LL C,k1,k2,b1;
LL poww(LL a,LL b)
{
LL res=a,ans = 1 ;
while(b)
{
if(b&1) ans = (ans*res)%C ;
b>>=1 ;
res= (res*res)%C ;
}
return ans%C;
}
int main()
{
LL tot = 1;
while(scanf("%lld %lld %lld %lld",&C,&k1,&b1,&k2)!=EOF)
{
printf("Case #%d:\n",tot++);
LL s = 0;
for(LL i = 1; i<C; i++) ///枚舉a
{
bool ok = true;
LL b = C - poww(i,k1+b1); ///求b
if(b<=0) continue;
for(LL n =1 ; n<=2; n++) ///篩選1,2即可
{
LL rr = n;
if(((LL)poww(i,k1*rr+b1)+(LL)poww(b,k2*rr-k2+1))%C!=0)
{
ok = false;
break;
}
}
if(ok)
{
printf("%lld %lld\n",i,b);
s++;
}
}
if(!s) ///無解!
{
puts("-1");
}
}
return 0;
}