编程练习:Biorhythms

POJ 1006 Biorhythms(中国剩余定理,63 ms) 一、题目描述 Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 154722 Accepted: 50271(2020/1/13) Description Some people believe that there are three cycles in a person’s life that sta... 阅读详情

http://poj.org/problem?id=1006


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.

分析: 

1)如果 0 0 0 开始的直接求最小公倍数, 最后要大于d

2)如果 非 0 0 0 且 p,e,i 由小到大排列,且 < 23,28,33 那么

     k = k +23 (k初始值 p) 

    if ( k%23 == p && k%28=e && p%33=i) 这 k 找到  ( 如果能把k调整为0, 则就不用判断k了)

3)   p,e,i 并非小到大排列,并且很大

  调整,让 p +-=23, i +=28, e   =+ 33, 让其达到条件 2) 

防止通达信公式被盗?手把手教你用DLL加密+互联网验证(含易语言后台管理) 本文详细介绍了如何通过DLL加密与互联网验证技术保护通达信公式安全。从DLL加密实现、设备绑定到易语言后台管理,提供了一套完整的防护方案,有效防止公式被盗用。重点讲解了互联网验证登录和绑定设备等核心技术,帮助量化交易者守护核心资产。 阅读详情

相关推荐

STM32H743 SD卡读写避坑实录:CubeMX配置MDMA给FATFS,我的FreeRTOS项目踩了哪些雷?

本文详细解析了STM32H743在CubeMX配置中结合SDMMC、MDMA与FATFS的实战避坑指南,特别针对FreeRTOS环境下的SD卡读写问题提供了解决方案。从时钟配置到FATFS参数设置,再到DMA缓存维护和FreeRTOS集成技巧,帮助开发者高效解决数据损坏、DMA传输错误等常见问题,提升项目稳定性。

weixin_30878501的博客 503

【POJ】1006 Biorhythms

Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 85493   Accepted: 25926 Description Some people believe that there are three cycles in a person'

Manjushri的知识库 862

spark 适配达梦数据库

spark 适配达梦数据库 版本 spark3.0.0 scala2.12.10 DM Database Server 64 V8 步骤一: 引驱动包: SBT方式: "com.dameng" % "Dm8JdbcDriver18" % "8.1.0.157", maven方式: <dependency> <groupId>com.dameng</groupId> <artifactId>Dm8JdbcDriver18</artifac

_@Eva@_的博客 2095

1006:Biorhythms

x += 23)//把各自的高峰天打张表。p = p % 23;//得到在一个周期内高峰第几天。

qq_53826699的博客 331

2026中银杯区块链赛项备赛全攻略:从任务书拆解到高分技巧

区块链技术正从概念走向工程化落地,其核心价值在于通过分布式账本、智能合约与共识机制,构建可信、透明、可追溯的业务协作网络。在供应链溯源、存证、资产流转等场景中,区块链应用已从单一技术验证转向完整业务系统交付,这对开发者的综合能力提出了更高要求。对于职业院校技能大赛而言,选手不仅需要掌握联盟链底层搭建、Solidity合约开发、前后端应用联调等技术,还需具备规范交付与团队协作的工程素养。围绕2026年中银杯湖北省职业院校技能大赛区块链技术应用赛项,本文深入拆解任务书模块与评分逻辑,梳理底层链搭建、智能合约开发

weixin_27960253的博客 344

2023电视专用!安卓电子相册APP避坑指南(附开源代码)

本文针对2023年智能电视用户,提供安卓电子相册APP的避坑指南与实战教程。文章详细解析了电视端相册应用的常见广告与兼容性陷阱,并指导用户如何安全获取、部署纯净的APK应用,通过核心设置实现无广告的个性化图片轮播体验,最终打造专属的家庭回忆墙。

weixin_29012677的博客 502

[POJ 1006] Biorhythms C++解题

Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 107569 Accepted: 33365 Description Some people believe that there are three cycles in a...

diankong6347的博客 327

告别GIS软件!用R语言ggplot2+ggmapcn绘制出版级世界地图(附5种投影对比图)

本文提供了一份完整的实践指南,教你如何利用R语言及其强大的ggplot2生态系统,结合ggmapcn包,绘制出出版级的世界地图。文章详细对比了五种经典地图投影(如摩尔维德、罗宾森投影)的代码实现与视觉差异,并讲解了如何添加比例尺、指北针等专业元素,最终导出高清PDF,实现从数据分析到专业可视化的全流程代码化操作,彻底告别传统GIS软件。

p5l2m9n4o6q的博客 422

Biorhythms

Time Limit:1000MS Memory Limit:10000K Total Submissions:135099 Accepted:43146 Description Some people believe that there are three cycles in a person's life that sta...

weixin_34177064的博客 197

pytorch实现基本的logistic和softmax回归实验(手动+torch)

前提:不是前馈神经网络,没有隐藏层。 一:Logistic回归实验–人工构造数据集,手动构造模型 要求: 动手从0实现logistic回归,实现二分类,人工构造数据集,并分析loss、训练集、测试集的准确率。(要求从零实现二元交叉熵) 实验过程: 1.1人工构造数据集 1. # #自定义数据---训练集 2. num_inputs = 2 3. n_data = torch.ones(1500, num_inputs) # 数据的基本形态 4. x1 = torch.normal(2 * n_d

qq_37534947的博客 1万+

选型不再靠感觉:一文看懂 SAP Event Mesh 与 SAP Integration Suite, advanced event mesh 的能力边界

本文对比分析了SAP Event Mesh与SAP Integration Suite, advanced event mesh的差异。SAP Event Mesh适合轻量级场景,主要用于SAP系统间异步通信,支持AMQP、MQTT等协议,消息大小限制为1MB。而advanced event mesh面向企业级事件网络,提供跨云/本地部署、事件治理、监控等高级功能,支持30MB消息和更大存储容量。选择时需考虑业务规模、实时性要求、治理需求等因素:单一SAP生态内扩展可选Event Mesh;跨区域、多云环境

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 152

一本通1639:Biorhythms

【代码】一本通1639:Biorhythms。

liu12345635的博客 266

使用 Visual Studio Code 连接 ABAP On-Premise 系统做开发的详细配置步骤

本文详细介绍了如何在Visual Studio Code中通过ABAP Development Tools扩展连接ABAP On-Premise系统。关键步骤包括:通过Ctrl+Shift+P打开命令行面板选择「ABAP: New Destination...」创建RFC连接(仅支持SSO单点登录),选择本地SAPGUI中已有的系统,输入Client ID、语言和用户名(无需密码),最后将目标系统添加到工作区即可开始开发。文章强调了企业安全考虑下仅支持SSO的设计理念,并展示了连接配置的JSON格式示例。整

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1021

POJ Problem Id1006 :Biorhythms ACM 编程练习

http://poj.org/problem?id=1006 问题描述: 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 physica

玄霄 788

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

POJ编程3----Biorhythms

POJ编程3----Biorhythms题目要求程序思路代码示例 题目要求 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, emotiona...

blogs of keep loving 241

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

算法练习之:Biorhythms

Biorhythms Time Limit:1000MSMemory Limit:10000KB 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 cy...

diansuoku1565的博客 175

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

poj1006 Biorhythms

A - Biorhythms Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1006 Appoint descripti

苏苏爱自由 2502

Biorhythms--题解

题目链接:http://poj.org/problem?id=1006 难道只有我自己看不懂这道题吗?我始终没搞明白它和中国剩余定理有什么关系。。 刚刚终于看明白了,比着题目一点一点扣字眼看明白了,还画出了一张神来之作-- 是的,简直完美(。)  题目大意:(要敲住重点)    从人生下来(遥远的起点,不用考虑),就有三个周期,T1=23,T2=28, T3=33,一个周期内有一天是...

二喵君的博客 516

acm-Biorhythms

Biorhythms 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 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, em

zzyy17的专栏 782

hdu 1370:Biorhythms(中国剩余定理)

hdu 1370:Biorhythms(中国剩余定理) 题目链接 题意: 看题意一脸懵逼,原来就是求a 其中 (a+d)%23=p (a+d)%28=e (a+d)%33=i (d,p,e,i 如题意) 题解: 很明显的中国剩余定理,虽然证明有点没搞明白,但是有模板啊。。。。 至于中国剩余定理的原理,以前看的一篇博客感觉写的挺好的 https://blog.csdn.net/bo_jwolf/ar...

serendipity的博客 323

POJ 1006 Biorhythms

POJ 1006 Biorhythms 1.题目的大意是给定三个数a1, a2, a3,求出一个数,这个数除以23, 28, 33得到的余数为a1, a2, a3; 2.从网上查到用中国余数定理,以下是找到的资料: 若某数x分别被d1、、…、dn除得的余...

dayong9372的博客 96

zoj1160 Biorhythms

//zoj1160 Biorhythms //Accepted 1160 C++ 00:00.02 396K /* Chinese remainder theorem a1 = p, a2 = e, a3 = i m1 = 23

fairylan的专栏 923

poj 1006 Biorhythms

<br />//POJ 1006 Biorhythms (中国剩余定理) #include <cstdio> int mo(int a,int b,int c) { a*=b; int d=a; while (a%c!=1) a+=d; return a; } int main() { int a,b,c; int d; int count=0; while (scanf("%d%d%d%d",&a,&b,&c,&d) ) { if (a==-1

birdforever的专栏 502

1006 Biorhythms

貌似有O(1)数学解法,直接O(n)过了....有空再研究//4476569_AC_344MS_428K /***********************************************************************       Online Judge   : POJ*       Problem Title  : Biorhythms

twilightgod的专栏 610

POJ-1006 Biorhythms 中国剩余定理

POJ-1006 Biorhythms 文章目录POJ-1006 Biorhythms思路:推导细节AC代码 由于题目过于冗长,在此只描述大致题意:人出生就伴随:体力,情感和智力三个生理周期,他们的周期分别为23天,28天,33天,每个周期内有一天为该阶段的峰值,这一天人在对应的方面的表现的最好。一般情况下,这三天不会在同一天,现在分别给出三个日期,分别对应体力§,情感(e),智力(i)出现峰值的日期,以及一个起始日期(d),问:从起始日期开始,最少经过多少天三个方面同时到达峰值。 思路: 关于中国剩余

碳碳双键 212

POJ 1006 Biorhythms - 数学逻辑

POJ 1006 Biorhythms 题意:三个正整数的最小公约数相关。难度:1星。 根据相关逻辑关系直接计算,也不算复杂。注意,在current day就是next triple peak day时,答案应为一个周期(21252);next triple peak day有可能小于current day,此时答案应在下一个周期内(即再加21252)。 讨论区中有同学用“中国剩余定理”解决

ChenK在学习! 774
上一篇: 编程练习:Spell checker
下一篇: Linux 下 USB-serial 端口的使用
span76
博客等级 码龄18年 117粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值