| ||||||||||
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> # include <cstdio> long x1,k1; using namespace std; long gcd(long a,long b) { if(b==0) return a; else return gcd(b,a%b); } void xy(long a,long l) { if(l==0) { x1=1; k1=0; return; } xy(l,a%l); long v=x1; long n=k1; x1=n; long ab=a/l; k1=v-ab*n; } int main() { long x,y,m,n,l,s; while(scanf("%ld%ld%ld%ld%ld",&x,&y,&m,&n,&l)!=EOF) { long c=x-y; long a=n-m; if(a==0) { cout<<"Impossible"<<endl; continue; } long al=gcd(a,l); if(c%al!=0) { cout<<"Impossible"<<endl; continue; } a=a/al; l=l/al; c=c/al; xy(a,l); s=(x1*c)%l; for(;;) { if(s<=0) s=s+l; else break; } cout<<s<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator