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:Leon_Xu at 2010-12-05 21:24:33 #include <stdio.h> int main(int argc, char* argv[]) { int x, y, m, n, L, dd, dv, ltimes, tmp, first; scanf("%d%d%d%d%d", &x, &y, &m, &n, &L); x %= L; y %= L; m %= L; n %= L; if(m>n) { dd = (x<y) ? y-x : L-(x-y); dv = m-n; } else if(m<n) { dd = x>y ? x-y : L-(y-x); dv = n-m; } else { printf("Impossible\n"); return 0; } tmp = dd; ltimes = 0; first = 1; while(1) { if(tmp%dv == 0) { ltimes += (tmp/dv); printf("%d\n", ltimes); break; } if( (!first) && (tmp >= dd) && (((tmp-dd)%dv) == 0)) { printf("Impossible\n"); break; } ltimes += tmp/dv+1; tmp = L + (tmp%dv-dv); first = 0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator