首页 > 代码库 > POJ 1006 Biorhythms
POJ 1006 Biorhythms
思路:伟大的中国同余定理。公式推导见这里:http://blog.csdn.net/shanshanpt/article/details/8724769
代码:
/* 中国剩余定理:出自《孙子算经》 */#include<stdio.h>#define MAX 21252int 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;}
POJ 1006 Biorhythms
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。