POJ 1006 Biorhythms 中国剩余定理
2013-12-11 22:05
507 查看
http://poj.org/problem?id=1006
人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是同一天。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现。
中国剩余定理的使用,不懂的看。。http://blog.csdn.net/murmured/article/details/17270579
根据题意可以得到如下式子( n + d ) % 23 == p; ( n + d ) % 28 == e; ( n + d ) % 33 == i;
然后就是中国剩余定理啦~
人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是同一天。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现。
中国剩余定理的使用,不懂的看。。http://blog.csdn.net/murmured/article/details/17270579
根据题意可以得到如下式子( n + d ) % 23 == p; ( n + d ) % 28 == e; ( n + d ) % 33 == i;
然后就是中国剩余定理啦~
#include<cstdio> int main() { int p,e,i,d; int kase=1; while(~scanf("%d%d%d%d",&p,&e,&i,&d)) { if(p==-1 && e==-1 && i==-1 && d==-1) break; int ans=(5544 * p + 14421 * e + 1288 * i-d) % 21252; if(ans <=0) ans+=21252; printf("Case %d: the next triple peak occurs in %d days.\n",kase++,ans); } return 0; }
相关文章推荐
- POJ1006-Biorhythms 中国剩余定理
- POJ 1006 ——Biorhythms 中国剩余定理模板
- poj 1006 Biorhythms 中国剩余定理
- POJ-1006 Biorhythms 中国剩余定理
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
- poj 1006 Biorhythms 中国剩余定理
- POJ 1006 Biorhythms 中国剩余定理/扩展欧几里得
- poj 1006 Biorhythms(中国剩余定理的应用)
- POJ 1006---Biorhythms【中国剩余定理】
- POJ 1006 Biorhythms [中国剩余定理]
- poj1006 Biorhythms 中国剩余定理
- POJ 1006 Biorhythms --中国剩余定理(互质的)
- poj 1006 Biorhythms 中国剩余定理
- POJ1006 Biorhythms(生理周期,中国剩余定理详述)
- 中国剩余定理 POJ 1006 Biorhythms
- poj 1006 Biorhythms 中国剩余定理
- POJ 1006 Biorhythms 中国剩余定理
- 中国剩余定理(CRT 孙子定理)——Biorhythms(POJ 1006)
- 【中国剩余定理】POJ 1006 & HDU 1370 Biorhythms
- Biorhythms(poj1006中国剩余定理)