/ 7FOJ / 题库 /

Friday the Thirteenth 黑色星期五

Friday the Thirteenth 黑色星期五

背景

  • Idea: USACO
  • Data: USACO
  • Solution: USACO
  • 题面: USACO
  • Translate: oistream

本题来自 USACO 1.2 Greedy Gift Givers

描述

Is Friday the \(13\text{th}\) really an unusual event?

每月 \(13\) 日恰逢星期五(“黑色星期五”——译注)是最不寻常的事情吗?

That is, does the \(13\text{th}\) of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the \(13\text{th}\) of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January \(1\), \(1900\) to December \(31\), \(1900+N-1\) for a given number of years, \(N\). \(N\) is positive and will not exceed \(400\).

也就是说,一个月的 \(13\) 日这一天恰好是星期五的概率是否低于是一周中其它日子(即星期一、二、三、四、六、日)的概率呢?为了回答这个问题,请你编写一个程序,计算出给定的 \(N\) 年中每月 \(13\) 日是星期一、二、三、...、日的概率。这 \(N\) 年自 \(1900\) 年 \(1\) 月 \(1\) 日起,至 \(1900+N-1\) 年 \(12\) 月 \(31\) 日止。\(N\) 由输入给定。

There are few facts you need to know before you can solve this problem:

为了解决这个问题,你必须知道下面的一些事实。

  • January \(1\), \(1900\) was on a Monday.
  • \(1900\) 年 \(1\) 月 \(1\) 日是星期一。
  • Thirty days has September, April, June, and November, all the rest have \(31\) except for February which has \(28\) except in leap years when it has \(29\).
  • 四月、六月、九月、十一月有 \(30\) 天;二月在平年(非闰年)有 \(28\) 天,在闰年有 \(29\) 天;其它的月份都有 \(31\) 天。
  • Every year evenly divisible by \(4\) is a leap year (\(1992 = 4 \times 498\) so \(1992\) will be a leap year, but the year \(1990\) is not a leap year)
  • 通俗解释 :四年一闰。
  • 被 \(4\) 整除的年份是闰年(例如因为 \(1992=4\times 498\) 所以 \(1992\) 年是闰年,但 \(1990\) 年不是)。
  • The rule above does not hold for century years. Century years divisible by \(400\) are leap years, all others are not. Thus, the century years \(1700, 1800, 1900\) and \(2100\) are not leap years, but \(2000\) is a leap year.
  • 通俗解释 :百年不闰,四百年再闰。
  • 上面的规则对被 \(100\) 整除的年份不适用。被 \(400\) 整除的年份是闰年,其它被 \(100\) 整除的年份不是闰年。因此, \(1700,1800,1900,2100\) 年都不是闰年,但 \(2000\) 年是闰年。

输入格式

One line with the integer \(N\).

一行一个整数 \(N\)。

输出格式

Seven space separated integers on one line. These integers represent the number of times the \(13\text{th}\) falls on Saturday, Sunday, Monday, Tuesday, ..., Friday.

一行 \(7\) 个用空格隔开的整数,分别为每月 \(13\) 日恰逢 星期六,日 ,一,二,...,五的次数。

样例

输入样例1

20

输出样例1

36 33 34 33 35 35 34

数据规模与约定

\(0\lt N\leq 400\)。

说明与提示

Do not use any built-in date functions in your computer language.

不要使用任何你使用的语言中的与日期相关的内建函数(time() 不是内建函数——译注)。

Don't just precompute the answers, either, please.

请不要打表。(鉴于国内 OI 竞赛允许打表,因此本 OJ 上的此题也允许打表——管理员提醒)

Note that the start year is NINETEEN HUNDRED, not NINETEEN NINETY.

注意起始年份是 \(1900\),不是 \(1990\)。 \(\sout\textsf{不过这个提示似乎有点过时...——译注}\)

信息

ID
1106
难度
2
分类
模拟 点击显示
标签
递交数
1
已通过
1
通过率
100%
被复制
1
上传者

相关

在下列训练计划中:

USACO 题目合集