Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
如果遇到 好人帮忙 指点一下啊!(代码)#include <iostream> using namespace std; long gcd(long m,long n,long l); int main() { long x,y,m,n,l; cin>>x>>y>>m>>n>>l; long q; if(y>x)q=y-x; else q=x-y; if(m==n||q%gcd(m,n,l)!=0) cout<<"Impossible"; long a,b,c; a=m-n;c=y-x; long long k; for(b=1;b<l;b++) { k=a*b-c; if(k%l==0) {cout<<b;break;} } return 0; } long gcd(long m,long n,long l) { long k; if(m-n<0)k=n-m; else k=m-n; long a,b; if(k>=l){a=k;b=l;} else {a=l;b=k;} long q,r; do { q=a/b;r=a%b; a=b;b=r; }while(r!=0); return a; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator