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:大牛们帮忙看看我这怎么错的吧! Posted by:WhoMovedMyRP at 2006-03-08 14:25:18 > #include <stdio.h> > > __int64 e_gcd(__int64 a, __int64 b, __int64 *x, __int64 *y) > { > __int64 x1, y1, p; > if (b == 0) > { > *x = 1; > *y = 0; > return a; > } > > p = e_gcd(b, a % b, &x1, &y1); > > *x = y1; > *y = x1 - (a / b) * y1; > return p; > } > > __int64 abs(__int64 a) > { > return (a > 0) ? a : -a; > } > > int main() > { > __int64 x, y, m, n, L; > __int64 a, b, t, r, gcdans, lcmans, ans; > > while (scanf("%I64d %I64d %I64d %I64d %I64d", &x, &y, &m, &n, &L) != -1) > { > x %= L; > y %= L; > m %= L; > n %= L; > > if (x > y) > { > a = x - y; > b = (n - m + L) % L; > } > else > { > a = y - x; > b = (m - n + L) % L; > } > > gcdans = e_gcd(a, L, &t, &r); > lcmans = a / gcdans * L; > if (b % gcdans != 0) > { > printf("Impossible\n"); > } > else > { > ans = (b / gcdans * t + lcmans) % lcmans; ~~~~~~~~~~~~~~~~~~~~~~~~~~~这个地方也错了 > printf("%I64d\n", ans); > } > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator