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> #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