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.
Case 1: the next triple peak occurs in 1234 days.
Use the plural form ``days'' even if the answer is 1.
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
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.
一些人相信存在3种周期在人的生命中当人出生时,这三种周期分别是身体的,情感的,智力的,
它们每一周期的长度分别是23,28和33天,每个周期都有一个高峰值,在每个高峰的时候,每个人
都有最好的表现在相对的领域(身体的,情感的,智力的).举个列子,智力周期的高峰,
人会思维敏捷,精力容易高度集中。
我们想知道何时三个高峰落在同一天。对于每个周期,我们会给出从当前年份的第一天开始,
到出现高峰的天数(不一定是第一次高峰出现的时间)。
下一次三个高峰落在同一天的时间(距给定时间的天数)。
例如:给定时间为10,下次出现三个高峰同天的时间是12,
则输出2(注意这里不是3)。
输入:
(时间从当年的第一天开始计算)。d 是给定的时间,可能小于p, e, 或 i。
所有给定时间是非负的并且小于365, 所求的时间小于21252 。
输出
从给定时间起,
下一次三个高峰同天的时间(距离给定时间的天数)。
#include<iostream> #include<cstdio> using namespace std ; int main(){ int p,e,i,d,n=1; cin>>p>>e>>i>>d ; while(p!=-1 && e!=-1 && i!=-1 && d!=-1 ) { int l; for(l=d+1;l<=21252;l++) if((l-p)%23==0) break ; for(;l<=21252 ;l=l+23) if((l-e)%28==0) break ; for(;l<=21252;l=l+23*28) if((l-i)%33==0) break ; printf("Case %d: the next triple peak occurs in %d days.\n",n,l-d); n++ ; cin>>p>>e>>i>>d ; } return 0 ; }
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner sc = new Scanner(System.in) ; int p,e,i,d,n=1 ; p = sc.nextInt() ; e = sc.nextInt() ; i = sc.nextInt() ; d = sc.nextInt() ; while(p!=-1 && e!=-1 && i!=-1 && d!=-1 ) { int l; for(l=d+1;l<=21252;l++) if((l-p)%23==0) break ; for(;l<=21252 ;l=l+23) if((l-e)%28==0) break ; for(;l<=21252;l=l+23*28) if((l-i)%33==0) break ; System.out.printf("Case %d: the next triple peak occurs in %d days.\n",n,l-d); n++ ; p = sc.nextInt() ; e = sc.nextInt() ; i = sc.nextInt() ; d = sc.nextInt() ; } } }
1) 21252 >= x > d
2) (x-p)%23=0
3) (x-e)%28=0
4) (x-i)%33=0
// j从d+1 循环到21252, 如果 (j-p)%23==0,跳出循环
// j从上次跳出循环的值循环到21252,
如果 (j-e)%28==0,跳出循环
// j从上次跳出循环的值循环到21252,
如果 (j-i)%33==0,跳出循环
// 输出j-d
相关推荐
惠普HPLaserJetP1006黑白激光打印机驱动程序,官方最新驱动,是连接电脑的必备组件,能完美解决打印机不能识别或无法打印的问题,支持Win8/Win7/Vista/XP系统,有需要的就下载吧。参数品牌:惠普型号:P1006打印方式...
KPESD3V3S1UL DFN1006 3L KUU 规格书
hdoj1006 答案代码 解题代码 欢迎下载 亲~
POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析
目前最新的ActivePerl-5.10.1.1006-MSWin32-x86-291086.msi
安装hp打印机驱动提示缺失文件解决中的文件 hp1006SU.DLL
打印机驱动文件HP1006J.DLL,欢迎下载
f6flpy-x86_Win7_XP_11.1.0.1006.zip
hp 打印机驱动文件提示缺失文件解决的文件hp1006SM.exe
关闭HP1006MC.EXE,使其不再开机运行。
解决poj1006问题
装HP P1006或P1007的原驱动,即使是官方下载的驱动程序,依然无法识别,在设备驱动程序更新的时候依然会提示缺少 P1006CLP.dll,即使有这个文件,接下来还会提示缺少其它的文件。此文件包含所有缺失的文件,像TXT...
杭电oj题库1006的思路和代码 http://192.168.100.16/showproblem.php?pid=1006 109MS 220K 987 B
惠普p1006打印机 windows xp系统驱动扩展,可用于驱动安装时缺少dll使用
PM34-1006M网络变压器 ENC28J60用
p1006clp.dll
MX25L1006E, 3V, 1Mb, SPI flash Datasheet
KPESD5V0L1BL DFN1006 KUU 规格书
DLT 1006-2006 架空输电线路巡检系统.rar
DFN1006__SDA0511CBP.pdf