# poj-1006-Biorhythms

Description

Input

Output

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.```
```#include<iostream>
using namespace std;
int main()
{
int p,e,j,d,q=0;
cin>>p>>e>>j>>d;
while(p!= -1&&e!= -1&&j!= -1&&d!= -1)//p,e,j,d 为-1时跳出循环
{

int i;
for(i=d+1;i<21252;i++)
if((i-p)%23==0)break; //找到p第一个倍数
for(;i<21252;i+=23)//每次加23，保证是p的倍数，同时找e的倍数
if((i-e)%28==0)break;//找到p，e的公倍数
for(;i<21252;i+=23*28)//每次加上23*28，即遍历p，e的倍数，知道找到j的倍数
if((i-j)%33==0)break;//这是的i是p，e，j，的倍数
q++;
cout<<"Case "<<q<<": ";
cout<<"the next triple peak occurs in "<<i-d<<" days."<<endl;

cin>>p>>e>>j>>d;
}

return 0;
}```

87 篇文章14 人订阅

0 条评论

## 相关文章

991

### Scala兴衰史：暂时的没落或许是一个新的开始

5年前，Scala 似乎曾要成为编程语言中下一个佼佼者，因为它能够优雅得使用面向对象编程范式进行函数编程。 现如今，随着像 LinkedIn 和 Yammer ...

3694

2255

2835

3624

3957

3428

2996

1710

592