Saturday, 21 March 2009

POJ ( acm.pku.edu.cn ) 1006

早年做的


#include<iostream>
using namespace std;
const int rp=23,re=28,ri=33;
int nexttime(int p,int e,int i,int d)
{
int x=1;
while(x<=21252)
{
if( (x+d-p)%rp || (x+d-e)%re || (x+d-i)%ri ) x++;
else return x;
}
return x;
}
int main()
{
int p,e,i,d,n=0;
while(cin>>p>>e>>i>>d)
{
n++;
if(p==-1&&e==-1&&i==-1&&d==-1)break;
cout<<"Case "<<n<<": the next triple peak occurs in "<<nexttime(p,e,i,d)<<" days."<<endl;
}
return 0;
}

No comments:

Post a Comment