题解 | #Biorhythms#

Biorhythms

https://www.nowcoder.com/practice/aa66f85934c142f3af2da111dc864d9f

利用甘特图好理解些
|	| 23
|		| 28
|			| 33
保持两段不动,有一段(比如23)一直增加自身长度,当23*x减去28(33)剩余的还是28的整数倍,说明峰值重合。
|


#include<iostream>
using namespace std;
int main()
{
    int date;
    int p,e,i,d;
    cin>>p>>e>>i>>d;
    int count=0;
    int k=0;
    while(1)
    {  //甘特图
        e=e+28;
        k++;
        if((e-p)%23==0&&(e-i)%33==0&&e>d)
        {
            date=e-d;
            cout<<"Case: the next triple peak occurs in "<<date<<" days.";
            break;
        }

    }

}

全部评论

相关推荐

07-10 12:17
已编辑
商丘师范学院 Java
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 11:55
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务