最新消息:点击查看大S的省钱秘笈

POJ 2080 Calendar C++版

POJ题解 Slyar 96浏览 0评论

文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。

日历题,细心一点很容易。

Description

A calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units of time measurements of a calender system.
According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are leap years.
Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.

Input

The input consists of lines each containing a positive integer, which is the number of days that have elapsed since January 1, 2000 A.D. The last line contains an integer −1, which should not be processed.
You may assume that the resulting date won’t be after the year 9999.

Output

For each test case, output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek", where "DayOfWeek" must be one of "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" and "Saturday".

Sample Input

1730
1740
1750
1751
-1

Sample Output

2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday

Slyar:告诉你今天是2000-1-1,问你N天之后是哪年哪月哪日,星期几,月份和天数不满10的要补0。模拟就好了,细心一点。注意424、425这种数据。

转载请注明:Slyar Home » POJ 2080 Calendar C++版

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (3)

  1. 哈哈......
    李艺凡3年前 (2013-08-20)回复
  2. 电脑右下角有时间,点开到2000-1-1就可以看到了...
    Slyar4年前 (2012-08-23)回复
  3. 2000.1.1是周几???题目中为什么没说???
    匿名4年前 (2012-08-21)回复