原题如下:

Biorhythms
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 110700   Accepted: 34443

Description

Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respectively. There is one peak in each period of a cycle. At the peak of a cycle, a person performs at his or her best in the corresponding field (physical, emotional or mental). For example, if it is the mental curve, thought processes will be sharper and concentration will be easier. 
Since the three cycles have different periods, the peaks of the three cycles generally occur at different times. We would like to determine when a triple peak occurs (the peaks of all three cycles occur in the same day) for any person. For each cycle, you will be given the number of days from the beginning of the current year at which one of its peaks (not necessarily the first) occurs. You will also be given a date expressed as the number of days from the beginning of the current year. You task is to determine the number of days from the given date to the next triple peak. The given date is not counted. For example, if the given date is 10 and the next triple peak occurs on day 12, the answer is 2, not 3. If a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak. 

Input

You will be given a number of cases. The input for each case consists of one line of four integers p, e, i, and d. The values p, e, and i are the number of days from the beginning of the current year at which the physical, emotional, and intellectual cycles peak, respectively. The value d is the given date and may be smaller than any of p, e, or i. All values are non-negative and at most 365, and you may assume that a triple peak will occur within 21252 days of the given date. The end of input is indicated by a line in which p = e = i = d = -1.

Output

For each test case, print the case number followed by a message indicating the number of days to the next triple peak, in the form:

Case 1: the next triple peak occurs in 1234 days.

Use the plural form ``days'' even if the answer is 1.

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.

Source

East Central North America 1999
解题思路:
三个最小周期的最小公倍数,枚举的时候,跳着试。假设只有情商生理周期的高分的情况下,这一个和下一个高分的日子就不用试了,再试这一个高分的倍数以及其他高分的倍数。再试体力最高分的日子,看是不是体力最高分的日子和情商最高分的日子都是最高分的日子。求体力最高分的日子和情商最高分的日子都是最高分的日子的方法:体力最高分的日子的间隔和情商最高分的日子的间隔的最小公倍数。同理,找到三个最高分的日子。
代码:
#include<iostream>
#include<cstdio>
using namespace std;
#define N 21252

int main(){
int p,e,i,d,caseNo = 0;
while( cin >> p >> e >> i >> d && p != -1){
++ caseNo;
int k;
for( k = d+1; (k-p)%23 ; ++k);
for(; (k-e)%28; k+= 23);
for(; (k-i)%33; k+= 23*28);
cout << "Case " << caseNo <<
": the next triple peak occurs in" << k-d <<" days\n"; 
}
return 0;
}

POJ:1006--BIORHYTHM(生理周期计算)相关推荐

  1. Poj 1006 / OpenJudge 2977 1006 Biorhythms/生理周期

    1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Ti ...

  2. POJ 2977 生理周期 解题报告

    2977 : 生理周期 总时间限制: 1000ms 内存限制: 65536kB 描述 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高 ...

  3. PKU ACM 1006 生理周期

    题目链接:Biorhythms 生理周期 Description 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会 ...

  4. Bailian2977 生理周期【枚举+中国剩余定理】

    2977:生理周期 总时间限制: 1000ms 内存限制: 65536kB 描述 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰. ...

  5. c语言编程 生理周期的程序,生理周期(示例代码)

    题目链接: poj 1006  http://poj.org/problem?id=1006 NOI题库  http://noi.openjudge.cn/ch0201/1978/ Time Limi ...

  6. POJ 1006 Biorhythms

    题目大意: 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天每一个周期.中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏 ...

  7. OpenJ_Bailian 4148 生理周期

    题目地址: https://vjudge.net/problem/OpenJ_Bailian-4148 人生来就有三个生理周期,分别为体力周期.感情周期和智力周期,它们的周期长度分别为23天.28天和 ...

  8. 百练OJ:4148:生理周期

    描述 人生来就有三个生理周期,分别为体力周期.感情周期和智力周期,它们的周期长度分别为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,在智力周期的高峰,人 ...

  9. poj 1006(中国剩余定理+模板题)

    题意:人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天.一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好.通常这三个周期的峰值不会是同一天.现在给出三个 ...

最新文章

  1. [物理学与PDEs]第2章习题参考解答
  2. centos 如何登陆mysql_[CentOS 0010] CentOS 配置mysql允许远程登录
  3. JAVA不使用POI给Word文档添加水印
  4. 【position也可以很复杂】当弹出层遇上了鼠标定位(下)
  5. mysql模糊查询不会区分大小写_MySQL模糊查询(like)时区分大小写
  6. Map转xml格式字符串
  7. 在Ubuntu系统下如何将chrome浏览器的bookmarks导出到本地
  8. SpringBoot学习笔记(8):事物处理
  9. C# 定义了 7 种变量类别:静态变量、实例变量、数组元素、值参数、引用参数、输出参数和局部变量
  10. opencv3.4.3的DNN模块调用bvlc_googlenet.caffemodel实现图像分类
  11. HCIBench_2.3.1部署_VSAN_测试工具
  12. idea2020不显示光标所在位置的方法名
  13. hdu-2602POJ-3624---01背包裸题
  14. Android 动画分类
  15. 数据分析十年来电影票房数据
  16. java nio wakeup_Java NIO wakeup实现原理
  17. 【数据聚类】基于多元宇宙优化DBSCAN实现数据聚类分析附matlab代码
  18. 【线上沙龙】WeTest携手Testerhome共探DevOps下的质量保障
  19. pyecharts 在地图上根据经纬度和量值,画出散点图/热力图
  20. 【算法】牛顿迭代法求平方根的原理和误差分析

热门文章

  1. 综合题网络卡顿计算机网络,电脑网络不稳定该这么解决!~
  2. 推进养老服务智慧化 认知症障碍友好社区物联网平台
  3. 拜占庭鲁棒随机聚合的分布式学习方法
  4. 【pytorch系列】卷积操作原理解析与nn.Conv2d用法详解
  5. 蒙泰卡罗模拟应用求解pi近似值
  6. 软件开发管理与质量控制(一)
  7. POLYV敏捷项目管理
  8. Python实战:网络爬虫都能干什么?
  9. python刚入门的童鞋,按照这样学一个月就能开始月赚3000+
  10. MACD黄金交叉和死亡交叉