| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么WA?能给一些数据吗?#include <stdio.h>
__int64 x;
__int64 y;
__int64 Euclid(__int64 a,__int64 b)
{
if(a==0)
{
x=0;
y=1;
return b;
}
else
{
__int64 tmp=Euclid(b%a,a);
__int64 tx=y-b/a*x;
__int64 ty=x;
x=tx;
y=ty;
return tmp;
}
}
int main()
{
__int64 a,b,c,t,g,p,ant;
int k;
while(scanf("%I64d%I64d%I64d%d",&a,&b,&c,&k)&&(a||b||c||k))
{
t=1<<k;
g=Euclid(c,t);
p=b-a;
if(p%g!=0) printf("FOREVER\n");
else
{
t/=g;
ant=p/g*x;
ant%=t;
if(ant<0) ant+=t;
printf("%I64d\n",ant);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator