poj 1006(中国剩余定理)

#include<iostream>
/*
    23,28,33
    28*33=924
    23*33=759
    23*28=644
    924*a%23=1,a=6,924*a=5544
    759*a%28=1,a=19,759*a=14421
    644*a%33=1,a=2,644*2=1288
*/
using namespace std;
int main(){
    int p,e,i,d,day1,count = 0;
    while(scanf("%d%d%d%d",&p,&e,&i,&d)==4&&p!=-1){
        int S = ((5544*p+14421*e+1288*i)%(23*28*33)-d+21252)%21252;
        if(S==0)S = 21252;
        printf("Case %d: the next triple peak occurs in %d days.\n",++count,S);
    }
    return 0;
} 

 

posted @ 2021-11-06 17:12  智人心  阅读(51)  评论(0)    收藏  举报