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 |
好像还没题解framework: https://github.com/chu-mirror/probs @[main@] { int c1, c2, c3, s, n=0; while (scanf("%d%d%d%d", &c1, &c2, &c3, &s), c1 != -1 && c2 != -1 && c3 != -1 && s != -1) { int f; @{compute f from c1, c2, c3@} printf("Case %d: the next triple peak occurs in %d days.\n", ++n, f - s); } } @ @[compute f from c1, c2, c3@] { int n1, n2, m; @{compute n1 from c1, c2@} @{compute n2 from c1, c3@} @{compute m from n1, n2@} f = c1 + 23 * (n1 + 28 * m); f = MOD(f, (23 * 28 * 33)); if (f-s <= 0) f += 23 * 28 * 33; } @ @[compute n1 from c1, c2@] { int n, c; extended_gcd(23, 28, &n1, &n, &c); n1 *= c2 - c1; } @ @[compute n2 from c1, c3@] { int n, c; extended_gcd(23, 33, &n2, &n, &c); n2 *= c3 - c1; } @ @[compute m from n1, n2@] { int n, c; extended_gcd(28, 33, &m, &n, &c); m *= n2 - n1; } @ @[samples@] === 0 0 0 0 0 0 0 100 5 20 34 325 4 5 6 7 283 102 23 320 203 301 203 40 -1 -1 -1 -1 >>> Case 1: the next triple peak occurs in 21252 days. Case 2: the next triple peak occurs in 21152 days. Case 3: the next triple peak occurs in 19575 days. Case 4: the next triple peak occurs in 16994 days. Case 5: the next triple peak occurs in 8910 days. Case 6: the next triple peak occurs in 10789 days. @ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator