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 |
Re:你测一下这一题讨论中的几个数据吧,这么乘的话,数据早就越界了In Reply To:Re:你测一下这一题讨论中的几个数据吧,这么乘的话,数据早就越界了 Posted by:8013 at 2003-12-13 14:23:11 #include "stdio.h" #define false 0 #define true 1 int main() { int x, y, m, n, L, count=0, sA, sB, speDif, i; int state = false; scanf("%d %d %d %d %d", &x, &y, &m, &n, &L); if(m>n) { speDif = m-n; if(x>y) { for(i=0; i<speDif; i++) { if(((i+1)*L-x+y)%speDif == 0) { state = true; printf("%d", ((i+1)*L-x+y)/speDif); return 0; } } if(state == false) printf("Impossible"); } else if(x<y) { for(i=0; i<speDif; i++) { if((i*L+y-x)%speDif == 0) { state = true; printf("%d", (i*L+y-x)/speDif); return 0; } } if(state == false) printf("Impossible"); } else {} } else if(m==n) { printf("Impossible"); } else { speDif = n-m; if(x>y) { for(i=0; i<speDif; i++) { if((i*L+x-y)%speDif == 0) { state = true; printf("%d", (i*L+x-y)/speDif); return 0; } } if(state == false) printf("Impossible"); } else if(x<y) { for(i=0; i<speDif; i++) { if(((i+1)*L-x+y)%speDif == 0) { state = true; printf("%d", ((i+1)*L-x+y)/speDif); return 0; } } if(state == false) printf("Impossible"); } else {} } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator