UVA756 Biorhythms

UVA756 Biorhythms

crt

crt裸题

因为模数已知所以有些值能直接求

#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll p,e,i,d,lcm=21252,ans,t;
int main(){
    while(1){
        cin>>p>>e>>i>>d;
        if(p==-1) break;
        ans=(5544*p+14421*e+1288*i-d+lcm)%lcm; //exgcd可以预先算
        printf("Case %lld: the next triple peak occurs in %lld days.\n",++t,ans ? ans:lcm);
    }return 0;
}

 

posted @ 2018-10-11 16:45  kafuuchino  阅读(97)  评论(0编辑  收藏  举报