【poj1006】 Biorhythms
http://poj.org/problem?id=1006 (题目链接)
题意
人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是同一天。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现。
Solution
http://www.cnblogs.com/MashiroSky/p/5918158.html
代码
// poj1004 #include<algorithm> #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<string> #include<map> #define MOD 1000000007 #define inf 2147483640 #define LL long long #define free(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout); using namespace std; inline LL getint() { LL x=0,f=1;char ch=getchar(); while (ch>'9' || ch<'0') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int main() { int p,e,i,d,T=0; while (scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF && p>-1 && e>-1 && i>-1 && d>-1) { int ans=(5544*p+14421*e+1288*i-d+21252)%21252; if (ans==0) ans=21252; printf("Case %d: the next triple peak occurs in %d days.\n",++T,ans); } return 0; }
This passage is made by MashiroSky.