标签:end arp highlight algo main space pac res turn
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; #define ll long long ll gcdd(ll a,ll b,ll &x,ll &y) { if(b==0) { x=1; y=0; return a; } ll res=gcdd(b,a%b,x,y); ll temp=x; x=y; y=temp-a/b*y; return res; } int main() { ll x,y,m,n,L,k,T; while(cin>>x>>y>>m>>n>>L) { ll gcd=gcdd(m-n,L,k,T); if((y-x)%gcd!=0) { cout<<"Impossible"<<endl; } else { ll mmp=(y-x)/gcd; k*=mmp; ll k0=k%abs(L/gcd); if(k0<0)k0+=abs(L/gcd); cout<<k0<<endl; } } return 0; }
标签:end arp highlight algo main space pac res turn
原文地址:https://www.cnblogs.com/carcar/p/9522854.html