首页 > 试题广场 >

Biorhythms

[编程题]Biorhythms
  • 热度指数:1870 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    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.

输入描述:
    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.


输出描述:
    Case: the next triple peak occurs in 1234 days.
    Use the plural form "days'' even if the answer is 1.
示例1

输入

0 0 0 0

输出

Case: the next triple peak occurs in 21252 days.
头像 健康快乐最重要
发表于 2020-03-05 15:40:20
一直没懂这个题什么意思。。。 最后也不太懂,看了别人的代码才勉强能接受。参考:https://www.cnblogs.com/zsboy/archive/2012/01/16/2323244.html大概是:给你三个天数(这三个天数是相对于这一年的某三天),然后在给你一个当前日期(也是相对于当前年的 展开全文
头像 chong_0428
发表于 2024-03-21 20:33:06
def shizidinli(a, b, c, d): for i in range(1, 21253): k = d + i if (k-a) % 23 == 0 and (k-b) % 28 == 0 and (k-c) % 33 == 0: 展开全文
头像 lyw菌
发表于 2023-03-10 09:43:45
//代码还是比较简单的,按天数枚举即可,就是英文最后有些读不懂了,还是查的翻译... #include "stdio.h" int main(){ int physical,emotional,intellectual;//分别为记录对应的日期(今年第几天出现) int date; 展开全文
头像 &阿萨
发表于 2023-03-05 21:44:15
利用甘特图好理解些 | | 23 | | 28 | | 33 保持两段不动,有一段(比如23)一直增加自身长度,当23*x减去28(33)剩余的还是28的整数倍,说明峰值重合。 | #include<iostream> using namespace std; int main 展开全文
头像 牛客7777779号
发表于 2023-03-06 20:40:08
#include <iostream> #include <cstring> #include <algorithm> #include <math.h> #include <string.h> #include <stdlib. 展开全文
头像 csyfZhang
发表于 2020-04-22 13:15:24
https://blog.csdn.net/csyifanZhang/article/details/105679635 ↑更好的阅读体验 这道题讲道理是中国剩余定理的模板题,枚举的复杂度有点小高。。 # 题目大意 题意:p e i分别代表的是三个高峰出现的时间 展开全文