加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

1006 biorhythms

发布时间:2020-12-14 05:07:27 所属栏目:大数据 来源:网络整理
导读:思路:与求最大公约数基本方法一致。虽然起点不同但终点仍旧一致,起点也可以求出相减为0的情况。 注意:不需要用暴力枚举的方法。我们在进行枚举时筛

思路:与求最大公约数基本方法一致。虽然起点不同但终点仍旧一致,起点也可以求出相减为0的情况。

注意:不需要用暴力枚举的方法。我们在进行枚举时筛选。以最小的23进行倍数增长一次试验。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 using namespace std;
 5 int main(){
 6     int p,i,e,d,count=1;
 7     while(true){
 8         cin>>p>>i>>e>>d;
 9         p%=23;i%=28;e%=33;
10         int t,h=0;
11         if(p==-1)
12             break;
13         while(true){
14             t=p+h++*23;
15             if(t<=d)continue;
16             if((t-i)%28==0&&(t-e)%33==0){
17                 //printf("Case %d: the next triple peak occurs in %d days.n",count++,t - d);
18                 cout<<"Case "<<count++<<": the next triple peak occurs in "<<t-d<<" days."<<endl;
19                 break;
20             }
21         }
22     }
23     return 0;
24 }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读