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 <stdio.h> int main() { __int64 x,y,m,n,L; bool flag; while(scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&L)!=EOF) { flag=false; if(x==y||x>=2000000000||y>=2000000000||m<=0||m>=2000000000||n<=0||n>=2000000000||L<=0||L>=2100000000) return 0; if(m==n) { if(x%L!=y%L) { printf("Impossible\n"); continue; } else { printf("1\n"); continue; } } x=x%L; y=y%L; __int64 t=0,s,v,r; if(m>n) { v=m-n; s=(y-x+L)%L; if(s==0) s+=L; r=s%v; while(1) { if(s%v==0) break; else if(t>0&&s%v==r) { flag=true; break; } t++; s+=L; } } if(m<n) { v=n-m; s=(x-y+L)%L; if(s==0) s+=L; r=s%v; while(1) { if(s%v==0) break; else if(t>0&&s%v==r) { flag=true; break; } t++; s+=L; } } if(flag) printf("Impossible\n"); else printf("%I64d\n",s/v); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator