| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
感觉这样比较简单,一个是peak点要大于d,一个是peak点小于等于21252,两种特殊情况比较坑#include <iostream>
using namespace std;
int GetMin(int *b){
if(b[0]<=b[1]&&b[0]<=b[2]){
return 0;
}
if(b[1]<b[0]&&b[1]<=b[2]){
return 1;
}
if(b[2]<b[0]&&b[2]<b[1]){
return 2;
}
return -1;
}
int main()
{
int b[4];
int i=0;
cin>>b[0]>>b[1]>>b[2]>>b[3];
while(b[0]!=-1){
switch(GetMin(b)){
case 0:b[0]+=23;break;
case 1:b[1]+=28;break;
case 2:b[2]+=33;break;
}
while(b[0]!=b[1]||b[0]!=b[2]||b[0]<b[3]){
switch(GetMin(b)){
case 0:b[0]+=23;break;
case 1:b[1]+=28;break;
case 2:b[2]+=33;break;
}
}
i++;
if((b[0]-b[3])==21252)
cout<<"Case "<<i<<": the next triple peak occurs in "<<21252<<" days."<<endl;
else
cout<<"Case "<<i<<": the next triple peak occurs in "<<(b[0]-b[3])%21252<<" days."<<endl;
cin>>b[0]>>b[1]>>b[2]>>b[3];
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator