poj1006

#include<iostream>
using namespace std;
int main()
{
	int p,e,i,d,count;
	count=0;
	while(cin>>p>>e>>i>>d&&p!=-1)
	{
		count++;
		for (int j=1;j<21253;j++)
		{
			int cur=d+j;
			if ((cur-i)%33==0)
			{
				if ((cur-e)%28==0)
				{
					if ((cur-p)%23==0)
					{
						cout<<"Case "<<count<<": the next triple peak occurs in "<<j<<" days."<<endl;
						break;
					}
				}
			}
		}
	}
	return 0;
}

你可能感兴趣的:(C++,poj)