@[_wakeup](/user/666741) `x=(x*a/gcdans%L/gcdans+L/gcdans)%(L/gcdans);` 这行丢了一个括号,应该是 `x=(x*a/gcdans%(L/gcdans)+L/gcdans)%(L/gcdans);`
by wYYSZLwSSY @ 2023-03-29 12:00:23
```cpp
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<cstring>
#include<stack>
#define ll long long
using namespace std;
ll x1,x2,x,y,n,m,L,b,a,gcdans;
ll gcd(ll a,ll b)
{
if(b==0)return a;
return gcd(b,a%b);
}
void exgcd(ll a,ll b)
{
if(b==0)
{
x=1,y=0;
return;
}
exgcd(b,a%b);
ll t=x;
x=y,y=t-a/b*y;
}
int main()
{
cin>>x1>>x2>>m>>n>>L;
a=x1-x2,b=n-m;
if(b<0)a=-a,b=-b;
gcdans=gcd(b,L);
if(a%gcdans!=0)cout<<"Impossible"<<endl;
else
{
exgcd(b,L);
x=(x*a/gcdans%(L/gcdans)+L/gcdans)%(L/gcdans);
cout<<x<<endl;
}
return 0;
}
```
by wYYSZLwSSY @ 2023-03-29 12:00:40
@[wYYSZLwSSY](/user/297683) 感谢dalao
by _wakeup @ 2023-03-29 12:03:08