当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1463:Anniversaries

题目描述
As far as our perceptions are concerned, a year runs from the midnight beginning the first of January to the midnight ending the 31st of December. Thus we can say that a year consists of:
12 months (of differing lengths)
52 (and a bit) weeks
365 days
8,760 hours
525,600 minutes
31,536,000 seconds.
Most of these numbers need to be adjusted in leap years.

A k'th anniversary of a date is usually defined as the same date (month and day) k years later, thus the 10th anniversary of 17th May 1983 is 17th May 1993. However we can also define other types of `versaries' - the 1 week-versary of 28th February 1984 is 6th March 1984.

If we define a convention of naming dates (and times if necessary) by specifying successively smaller periods separated by colons (that is as yyyy:mm:dd:hh:mm:ss) we can label the units using the same convention, that is y for years, d for days, w for weeks, h for hours, m for minutes and s for seconds (we cannot use months, they are too variable). We can then summarise the above examples as:
1983:5:17 + 10y -> 1993:5:17
1984:2:28 + 1w -> 1984:3:6
Note that the specification of an event has to be as least as precise (that is employ units at least as small) as the specification of the desired versary.

Write a program that will read in details of events and desired versaries and calculate the required date (and time if necessary). Bear in mind that a year is a leap year if it is divisible by 4 unless it is divisible by 100 as well, in which case it is only a leap year if it is divisible by 400; thus 1984 and 2000 are leap years, but 1900 is not.

输入解释
Input will consist of a series of lines, each line a specification of an event and a desired versary. The input will follow the format shown below, except that where one space is shown there may be more than one space. The event will be specified at least to the same precision as the desired versary. All events will start in this century, and no versary will be more than 100 years (or equivalent). Note that midnight starts a day rather than terminates it and thus is written as 0:0:0 and not as 24:0:0. The file will be terminated by a line consisting of a single 0.

输出解释
Output will consist of a series of lines, one for each line of the input. Each line will consist of the specification of the desired versary, to the same precision as given in the input, in the format shown below.

输入样例
1983:5:17    10 y
1984:2:28    1   w
1993:7:25:13:23 5 h
0
输出样例
1983:5:17 + 10y -> 1993:5:17
1984:2:28 + 1w -> 1984:3:6
1993:7:25:13:23 + 5h -> 1993:7:25:18:23
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1463

最后修改于 2020-10-25T22:45:11+00:00 由爬虫自动更新

共提交 147

通过率 90.48%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)