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 |
为什么会WA啊???????#include<iostream> #include<stdio.h> using namespace std; int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } void ex_eulid(int a,int b,int &m,int &n) { if(b==0) { m=1; n=0; return; } ex_eulid(b,a%b,m,n); int t; t=m; m=n; n=t-a/b*n; } int main() { int x,y,m,n,l,a,b,c,r,j1=0,j2=0,t; while(scanf("%d%d%d%d%d",&x,&y,&m,&n,&l)!=EOF) { a=n-m; b=l; c=x-y; r=gcd(a,b); if(c%r) { printf("%s\n","Impossible"); continue; } a/=r; b/=r; c/=r; //cout<<a<<b<<c<<endl; ex_eulid(a,b,j1,j2); t=c*j1/b; j1=c*j1-t*b; if(j1<0) { if(b>0)j1+=b; else j1-=b; } printf("%d\n",j1); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator