摘要:就是加啊加啊加,加过的。。^_^
#include <iostream>
using namespace std;
const int p_cycle = 23;
const int e_cycle = 28;
const int i_cycle = 33;
void operation(int & p, int & e, int & i)
{
int temp = (p < e? p : e);
temp = (temp < i? temp : i);
if(temp == p){
p += p_cycle;
return;
}
if(temp == e){
e += e_cycle;
return;
}
if(temp == i){
i += i_cycle;
return;
}
}
int main()
{
int index = 1;
while(true){
int p, e, i, d;
cin >> p >> e >> i >> d;
if( p == -1 ){
break;
}
while(p > d ){
p -= p_cycle;
}
while(e > d ){
e -= e_cycle;
}
while(i > d ){
i -= i_cycle;
}
while(true){
if( p==i && i==e && p > d){
cout << "Case " << index++ << ": the next triple peak occurs in " << p-d << " days." << endl;
break;
}
operation(p, e, i);
}
}
return 0;
}