poj 1006 hdu1370 Biorhythms

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define maxn 1000000
using namespace std;
int T;
int main(){
    int p,e,k,d;
    int ca=1;
    while(cin>>p>>e>>k>>d,p!=-1&&e!=-1&&k!=-1&&d!=-1){
       int ans;
         for(int i=1;i<=10000000;i++)
               if((i-p)%23==0&&(i-e)%28==0&&(i-k)%33==0){
                   ans=i;
                   //cout<<i<<"Jj"<<endl;
                   break;
               }
         ans-=d;
         if(ans<=0)
           ans+=21252;//加了此语句就过了那组数据
          printf("Case %d: the next triple peak occurs in %d days.\n",ca++,ans);


    }


}
对于此水题,我只想骂一句这跟中国剩余定理毛关系啊,干嘛弄那么复杂,害我看了半天什么剩余定理,扯淡,一开始我就是对的, 只是有组数据没过,poj discuss中有。

你可能感兴趣的:(poj,水题)