标签:style blog http color io ar div art sp
思路:伟大的中国同余定理。公式推导见这里:http://blog.csdn.net/shanshanpt/article/details/8724769
代码:
/* 中国剩余定理:出自《孙子算经》 */ #include<stdio.h> #define MAX 21252 int main() { int p, e, i, d, n, count = 0; while( scanf("%d%d%d%d", &p, &e, &i, &d) != EOF ) { count++; if(p == -1 && e == -1 && i == -1 && d == -1) { break; } n = ( 5544 * p + 14421 * e + 1288 * i - d ) % MAX; if( n <= 0 ) // 范围限制 { n += 21252; } printf("Case %d: the next triple peak occurs in %d days.\n", count, n ); } return 0; }
标签:style blog http color io ar div art sp
原文地址:http://www.cnblogs.com/ltwy/p/3984296.html