| ||||||||||
| 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:first at 2003-11-01 19:59:11 你用这个程序试试? submit了5次,最快一次40毫秒。
#include <stdio.h>
int main(void)
{
int j, p, e, i, d, days[23][28][33];
p = e = i = 0;
for(j = 0; j < 21252; j++)
{
days[p][e][i] = j;
p = p == 22 ? 0 : p + 1;
e = e == 27 ? 0 : e + 1;
i = i == 32 ? 0 : i + 1;
}
for(j = 0; scanf("%d%d%d%d", &p, &e, &i, &d) != EOF && p >= 0 && e >= 0 && i >= 0 && d >= 0; j++)
{
p %= 23;
e %= 28;
i %= 33;
printf("Case %d: the next triple peak occurs in %d days.\n", j + 1, (days[p][e][i] - d + 21251) % 21252 + 1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator