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:Nstd at 2010-08-06 22:53:08 #include <cstdio> int main() { int p, e, i, d, n, t = 0; while(scanf("%d%d%d%d", &p, &e, &i, &d), p != -1) { p %= 23; e %= 28; i %= 33; n = i; while(n % 28 != e) n += 33; while(n % 23 != p) n += 924; n -= d; if(n <= 0) n += 21252; printf("Case %d: the next triple peak occurs in %d days.\n", ++t, n); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator