Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

WA到跪，求数据，用的是1LL<<k, 能过样例，还有讨论里给的数据，但是还是WA

Posted by byijie at 2012-11-05 10:31:53 on Problem 2115 and last updated at 2012-11-05 10:35:36
```#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long A,B,C,K,x,y;
int ex_gcd(long long a,long long b)
{
if(b==0)
{
x=1,y=0;
return a;
}
else
{
int ans=ex_gcd(b,a%b);
int t=x;
x=y;
y=t-a/b*y;
return ans;
}
}
void solve(long long a,long long b,long long n)
{
x=y=0;
long long gcd=ex_gcd(a,n);
if(b%gcd!=0)
//        printf("FOREVER\n");
cout<<"FOREVER"<<endl;
else
{
x=(x*(b/gcd))%n;
long long t=n/gcd;
x=(x%t+t)%t;
//        printf("%ld\n",x);
cout<<x<<endl;
}
}
int main()
{
long long D,a,b,n;
while(cin>>A>>B>>C>>D)
{
if(A==0&&B==0&&C==0&&D==0)
break;
D=1LL<<K;
//        cout<<D<<endl;
a=C,b=B-A,n=D;
//        cout<<n<<endl;
solve(a,b,n);
}
return 0;
}
```

Followed by:

User ID:
Title:

Content: