Biorhythms(生物周期)

Time Limit: 1000 ms Memory Limit: 10000 KiB

Problem 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**(周期 p, e,i )** 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.

一开始也没有思路,看看了别人的用的中国剩余定理 (好吧不会,面对困难不能放弃~ 奥里给~),

学渣的我,结合了好多例子终于看明白了。大致这样吧。 23 28 33 是 三个周期。要我们求一个数 n 。
使得 n = p (mod 23) ; n = e (mod 28) ; n = i (mod 33) ; (也就是 n % 23 = p )
p , e , i, d 是要求我们输入的 , p 对应 n % 23 的余数 ; e 对应 n % 28 的余数 ; i 对应 n % 33 的余数 。 d 是开始的天数 (就是 当 d = 10 , 若 发生 重叠的天数是15 那么 n = 15 - 10 = 5 天 )

做法
1) 例出下列式子。
n = p (mod 23) ; n = e (mod 28) ; n = i (mod 33) ;
2)
n = 1 (mod 23); n = 0 (mod 23); n = 0(mod 23);
n = 0 (mod 28); n = 1(mod 28); n = 0(mod 28);
n = 0 (mod 33); n = 0(mod 33); n = 1(mod 33);
(按照列看,会发现 第一列的余数是 1 0 0 第二列的余数是 0 1 0 第三列是 0 0 1)
3)(按照列看 )
28×33×a mod 23 = 1 ; (第一列) ;
23×33×b mod 28 = 1 ; (第二列);
23×28×c mod 33 = 1 ; (第三列) ;
(仔细观察一下式子) a b c 可以用求出来,(for 循环一下~)
在这里 a = 6 ; b = 19 ; c = 2 ;
4)最后 n = (28×33×a×p + 23×33×b ×e + 23×28×c×i - n ) % lcm (23,28,33) ; (lcm 最小公倍数) ;

(表达有限…)

#include <iostream>// 1002 生物节律   acm
using namespace std;
int main()
{int p,e,i,d,n,j=1;cin>>p>>e>>i>>d;while(p!= -1 && e!= -1 && i!=-1 && d!= -1){n = ((5544*p)  + (14421*e) + (1288*i) - d) % 21252  ;if(n<=0){cout<<"Case "<<j++<<": the next triple peak occurs in "<<n+21252<<" days."<<endl;}else{cout<<"Case "<<j++<<": the next triple peak occurs in "<<n<<" days."<<endl;}cin>>p>>e>>i>>d;}return 0;
}

Biorhythms(生物周期)相关推荐

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

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

  2. 怎样建立产品体系?(五)- 产品生命周期

    产品生命周期是指,大多数产品所经历的从出现到消失4个阶段,引入期.成长期.成熟期和衰退期,并对营销策略.营销组合和新产品开发影响显著. 引入期(Introduction):为引入的产品建立市场,包括知 ...

  3. PKU ACM 1006 生理周期

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

  4. 薏米红豆粥的功效和实践演示

    熬薏米红豆粥有很多技巧和讲究.薏米很硬,红豆也很硬,假设已经煮在锅里,大概熬一个多小时不坏,这是一种浪费火灾或电力,它甚至可以把水烧开,原因症结. 我建议的方法有两种:第一种方法是在锅里加进去足够的水 ...

  5. 区块链将带来怎样的应用?

    链客,专为开发者而生,有问必答! 此文章来自区块链技术社区,未经允许拒绝转载. 在上一篇文章中,咱们聊到了区块链技术正在与大数据.云计算.物联网以及人工智能这些技术链接,随时可能碰撞出技术创新的火花, ...

  6. 薏米红豆粥功效及做法介绍

    熬薏米红豆粥是有非常多技巧和讲究的.薏米非常硬,红豆也非常硬,假设放在锅里一直熬,大概熬一个多小时还不烂,非常浪费火或者电,并且搞不好还会把水烧干,造成糊底. 我建议的方法有两种:第一种方法是在锅里加 ...

  7. 数仓是如何与“夏令时”愉快的玩耍?

    摘要:主要讲述夏令时的起源,发展,标准化以及如何在GaussDB中查询任一时区的夏令时规则. 本文分享自华为云社区<DWS如何与"夏令时"愉快的玩耍!>,原文作者:le ...

  8. 【英语学习】【WOTD】circadian 释义/词源/示例

    文章目录 Podcast circadian *adj.* [ser-KAY-dee-un] Definition Did You Know? Examples Bonus Podcast circa ...

  9. □□□□□□(此处略去X个字)

     看过贾平凹<废都>的朋友们可不要对我的标题浮想连翩.主要是近来一直心情不好,想骂两句又不愿意你们见到我粗俗的一面,只要借贾老师省略字的方式一用!至于具体内容是什么,想必朋友们大都可以猜到 ...

最新文章

  1. Java项目:养老院管理系统(java+SSM+JSP+Easyui+maven+mysql)
  2. 报告:AI岗年薪下降8.9%,收入不及2018年
  3. 【PC工具】文件压缩解压工具winrar解压缩装机必备软件,winRAR5.70免费无广告
  4. 十二省联考2019游记
  5. 知识图谱源码详解【八】__init__.py
  6. c# 带返回值的action_C#委托的介绍(delegate、Action、Func、predicate)
  7. 太神奇!波士顿动力又出新视频!Spot 机器狗这次竟学会了跳绳...
  8. 《深入理解 Spring Cloud 与微服务构建》第九章 熔断器 Hystrix
  9. JavaWeb——springMVC、mybatis与spring的整合
  10. pythonplot下载_Matplotlib for Python Developers PDF 下载
  11. 国产计算机设备,国产计算机报价
  12. 疯狂Java讲义笔记
  13. 苹果铃声制作(流水是操作记录)
  14. 相机等效焦距和视场角计算
  15. Java--制作乱字游戏
  16. unity如何插入图片_unity 图片导入及其使用方法
  17. 宠物商店信息管理系统
  18. NOIP2017提高组复赛总结
  19. 【问卷调查发布系统的设计与实现】
  20. omnipeek查询设备发送beacon时同一信道两个beacon发送间隔

热门文章

  1. 听说有些老铁,要感谢下大师兄?里边请,聊一聊人生。
  2. 企业想申报高新技术企业如何规划
  3. 属猴人性格及一生运势怎么样?
  4. mysql tinyint 2_mysql中Tinyint(1)、Tinyint(2)
  5. ie浏览器打不开,没有注册类别
  6. 济南市认定高新有什么好处
  7. “System.Runtime.InteropServices.COMException (0x80070422): 无法启动服务”解决方法
  8. 正态分布、泊松分布和伯努利分布
  9. 数据依赖和控制依赖 Data Dependence and Contol Dependence
  10. CSS设置样式的三种方式