中国剩余定理模板题,线下算出23,28,33的同余有奇效。
#include<cstdio>
int main(){
for(int p,e,i,d,count=1;scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF&&p!=-1&&e!=-1&&i!=-1&&d!=-1;count++)
printf("Case %d: the next triple peak occurs in %d days.\n",count,((5544*p+14421*e+1288*i-d)%21252)<=0?((5544*p+14421*e+1288*i-d)%21252+21252):(5544*p+14421*e+1288*i-d)%21252);
}
没错。。 O(1) 出答案。。