题目:
题意:
给出三个周期以及它们的峰值时间,求三个峰值在同一时刻是什么时候
分析:
因为 m m m是已知的,所以我们可以手推出 t t t,这样就可以直接 O ( 1 ) O(1) O(1)求解
代码:
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cctype>
#include<cmath>
#define LL long long
#define LZX Mu
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
int main()
{
int cnt=0,a=read(),b=read(),c=read(),d=read();
while(a!=-1&&b!=-1&&c!=-1&&d!=-1)
{
int ans=(5544*a+14421*b+1288*c-d+21252)%21252;
if(!ans) ans=21252;
printf("Case %d: the next triple peak occurs in %d days.\n",++cnt,ans);
a=read(),b=read(),c=read(),d=read();
}
return 0;
}