| Run ID | User | Problem | Result | Memory | Time | Language | Code Length | Submit Time |
| 6699970 | kingpro | 1006 | Accepted | 156K | 47MS | C++ | 261B | 2010-04-07 14:15:36 |
PKU 1006 Biorhythms
#include "stdio.h"
int main()
{
for(int p, e, i, d, c=0, n=0; scanf("%d %d %d %d", &p, &e, &i, &d) && p!=-1 && printf("Case %d: the next triple peak occurs in %d days.\n", ++c, (n=(5544*p+14421*e+1288*i-d+21252)%21252, n==0 ? 21252 : n)););
return 0;
}
中国剩余定理(参考: http://baike.baidu.com/view/838598.htm)
23*28*2 = 1288 (mod33) = 1
23*33*19 = 14421 (mod28) = 1
28*33*6 = 5544 (mod23) = 1
即解。
Author: CriusWuBlog: http://kingpro.cnblogs.comContact: kingpro@live.cn
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

posted on
浙公网安备 33010602011771号