原题
中国剩余定理板子题,详情参见百度百科
//此处5544,14421,1288为预先求好的M/m[i]在m[i]意义下的逆元
#include<cstdio>
#define MAX 21252
using namespace std;
int p,e,i,d,n,count;
int main()
{
while(~scanf("%d%d%d%d",&p,&e,&i,&d))
{
count++;
if(p==-1 && e==-1 && i==-1 && d==-1) break;
n=(5544*p+14421*e+1288*i-d)%MAX;
if (n<=0) n+=MAX;
printf("Case %d: the next triple peak occurs in %d days.
",count,n);
}
return 0;
}