#include <iostream>
using namespace std;
int f(int p,int e,int i ,int d);
int main()
{
int p,e,i,d;
for(int t = 1;;t++)
{
cin >> p >> e >> i >> d;
if((p >= 0)&&(e >= 0)&&(i >=0)&&(d >= 0) && (p <= 365) && (e <= 365) && (i <= 365) && (d <= 365))
cout << "Case " << t << ": the next triple peak occurs in " << f(p,e,i,d) << " days." << endl;
else
break;
}
return 0;
}
int f(int p,int e,int i ,int d)
{
int t4;
int t1 = p % 23;
int t2 = e % 28;
int t3 = i % 33;
for(t4 = 1;t4 <= 21252;t4++ )
if(((t4 + d - t1) % 23 == 0)&&((t4 + d - t2) % 28 == 0)&&((t4 + d - t3) % 33 == 0))
{return t4 ;
break;}
}
poj1006
最新推荐文章于 2018-08-30 20:26:23 发布