标签:des style http color os io strong ar
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 90518 | Accepted: 16492 |
Description
Input
Output
Sample Input
1 2 3 4 5
Sample Output
4
Source
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; __int64 x,y,m,n,l,d,a,b,c,temp; __int64 gcd(__int64 a,__int64 b) { __int64 t,d; if(b==0) { x=1; y=0; return a; } d=gcd(b,a%b); t=x; x=y; y=t-(a/b)*y; return d; } int main() { __int64 x1,k,ans; while(~scanf("%I64d%I64d%I64d%I64d%I64d",&x,&y,&m,&n,&l)) { a=n-m; b=l; c=x-y; d=gcd(a,b); if(c%d!=0) { printf("Impossible\n"); continue; } x=x*(c/d);//x为原不定方程的一组解。。 k=-x*d/b; ans=x+k*b/d; if(ans<0) ans=ans+b/d; printf("%I64d\n",ans); } return 0; }
poj1061青蛙的约会(扩展欧几里得),布布扣,bubuko.com
标签:des style http color os io strong ar
原文地址:http://blog.csdn.net/u014303647/article/details/38666665