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 |
你这个肯定超啊!这题要用扩展欧几里德的In Reply To:这样都超时,我实在精简不了了 Posted by:winter_1 at 2006-04-24 13:27:45 > #include <stdio.h> > #include <math.h> > void main() > { > int x,y,m,n,L; > scanf("%d %d %d %d %d",&x,&y,&m,&n,&L); > if(m==n){ > printf("Impossible\n"); > } > else{ > if(m>n){ > for(int k=1;;k++){ > if(((m-n)*k-(y-x))%L==0){ > printf("%d\n",k); > break; > } > } > } > else{ > for(int k=1;;k++){ > if(((n-m)*k+(y-x))%L==0){ > printf("%d\n",k); > break; > } > } > } > } > } > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator