标签:swap rip bsp ssi else include back 问题 blank
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 128285 | Accepted: 27962 |
Description
Input
Output
Sample Input
1 2 3 4 5
Sample Output
4
Source
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 #define LL long long 5 #define mp make_pair 6 #define pb push_back 7 #define inf 0x3f3f3f3f 8 void exgcd(LL a,LL b,LL &d,LL &x,LL &y){ 9 if(!b){d=a,x=1,y=0;} 10 else{ 11 exgcd(b,a%b,d,y,x); 12 y-=x*(a/b); 13 } 14 } 15 int main(){ 16 LL x,y,m,n,L; 17 while(cin>>x>>y>>m>>n>>L){ 18 if(m<n){ 19 swap(x,y); 20 swap(m,n); 21 } 22 LL a,b,d; 23 exgcd(m-n,L,d,a,b); 24 if((y-x)%d||m==n){ 25 puts("Impossible"); 26 continue; 27 } 28 printf("%lld\n",((a*(y-x)/d)%(L/d)+L/d)%(L/d)); 29 } 30 return 0; 31 }
标签:swap rip bsp ssi else include back 问题 blank
原文地址:https://www.cnblogs.com/zzqc/p/9471634.html