标签:
> 分析
1 /* ------------------------- 2 * 中国剩余定理 3 * -------------------------*/ 4 #include "stdio.h" 5 6 int main(void) 7 { 8 int p = 0, e = 0, i = 0, d = 0 ; 9 int days = 0 ; 10 int count = 0 ; 11 12 while(1) 13 { 14 scanf("%d %d %d %d", &p, &e, &i, &d) ; 15 if(-1 == d) 16 break ; 17 18 /* 5544 为28和33的公倍数, 且5544 % 23 = 1 */ 19 /* 14421 为23和33的公倍数,且14421 % 28 = 1 */ 20 /* 1288 为23和28的公倍数,且1288 % 33 = 1 */ 21 /* 21252 = 23 * 28 * 33 */ 22 days = (5544 * p + 14421 * e + 1288 * i) % 21252 ; 23 if(days <= d) 24 days += 21252 ; 25 26 printf("Case %d: the next triple peak occurs in %d days.\r\n", 27 ++count, days - d) ; 28 } 29 30 return 0 ; 31 }
POJ-1006: biorhythms 详解1: 中国剩余定理
标签:
原文地址:http://www.cnblogs.com/codesworld/p/4714694.html