题目描述:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 66042 | Accepted: 19373 |
Description
Input
当p = e = i = d = -1时,输入数据结束。
Output
采用以下格式:
Case 1: the next triple peak occurs in 1234 days.
注意:即使结果是1天,也使用复数形式“days”。
Sample Input
0 0 0 0 0 0 0 100 5 20 34 325 4 5 6 7 283 102 23 320 203 301 203 40 -1 -1 -1 -1
Sample Output
Case 1: the next triple peak occurs in 21252 days. Case 2: the next triple peak occurs in 21152 days. Case 3: the next triple peak occurs in 19575 days. Case 4: the next triple peak occurs in 16994 days. Case 5: the next triple peak occurs in 8910 days. Case 6: the next triple peak occurs in 10789 days.
解:
算法描述:其实就是求余数是否相同的问题
//poj accepted
#include"iostream"
#include"stdio.h"
using namespace std;
int main()
{
int p=0,e=0,i=0,d=0;
int j=1;
long s=1;
int ip=23,ie=28,ii=33;
while(p>-1&&e>-1&&i>-1&&d>-1)
{
cin>>p;
cin>>e;
cin>>i;
cin>>d;
if(p==-1||e==-1||i==-1||d==-1)
break;
else
{
while((s+d-p)%ip!=0||(s+d-e)%ie!=0||(s+d-i)%ii!=0)
{
s+=1;
}
cout<<"Case "<<j<<": ";
cout<<"the next triple peak occurs in "<<s<<" days."<<endl;
++j;
s=1;
}
}
return 1;
}