【USACO题库】1.1.3 Friday the Thirteenth黑色星期五
2016-08-15 11:25
393 查看
题目描述
13号又是星期五是一个不寻常的日子吗?
13号在星期五比在其他日少吗?为了回答这个问题,写一个程序来计算在n年里13
日落在星期一,星期二......星期日的次数.这个测试从1900年1月1日到
1900+n-1年12月31日.n是一个非负数且不大于400.
这里有一些你要知道的:
1900年1月1日是星期一.
4,6,11和9月有30天.其他月份除了2月有31天.闰年2月有29天,平年2月有28天.
年份可以被4整除的为闰年(1992=4*498 所以 1992年是闰年,但是1990年不是闰年)
以上规则不适合于世纪年.可以被400整除的世纪年为闰年,否则为平年.所以,1700,1800,1900和2100年是平年,而2000年是闰年.
请不要预先算好数据!
输入
一个整数n.
输出
七个在一行且相分开的整数,它们代表13日是星期六,星期日,星期一.....星期五的次数.
样例输入
20
样例输出
36 33 34 33 35 35 34
又是水题。。。
我们模拟当前的年、月、日、星期。把它们设为四个变量,之后不断更新知道达到要求。
每当日期等于13时,就把b[w]+1(B是答案,W是星期)
最后输出答案即可。
提示:输出答案时要先输出星期六、星期日,再输出星期一到星期五。
13号又是星期五是一个不寻常的日子吗?
13号在星期五比在其他日少吗?为了回答这个问题,写一个程序来计算在n年里13
日落在星期一,星期二......星期日的次数.这个测试从1900年1月1日到
1900+n-1年12月31日.n是一个非负数且不大于400.
这里有一些你要知道的:
1900年1月1日是星期一.
4,6,11和9月有30天.其他月份除了2月有31天.闰年2月有29天,平年2月有28天.
年份可以被4整除的为闰年(1992=4*498 所以 1992年是闰年,但是1990年不是闰年)
以上规则不适合于世纪年.可以被400整除的世纪年为闰年,否则为平年.所以,1700,1800,1900和2100年是平年,而2000年是闰年.
请不要预先算好数据!
输入
一个整数n.
输出
七个在一行且相分开的整数,它们代表13日是星期六,星期日,星期一.....星期五的次数.
样例输入
20
样例输出
36 33 34 33 35 35 34
又是水题。。。
我们模拟当前的年、月、日、星期。把它们设为四个变量,之后不断更新知道达到要求。
每当日期等于13时,就把b[w]+1(B是答案,W是星期)
最后输出答案即可。
提示:输出答案时要先输出星期六、星期日,再输出星期一到星期五。
相关文章推荐
- USACO1.1.3 Friday the Thirteenth(黑色星期五)
- Usaco 1.1.3 黑色星期五(Friday the Thirteenth)
- USACO 1.1.3 Friday the Thirteenth
- 洛谷 1202 [USACO1.1] 黑色星期五 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO之Section1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO1.1.3 Friday the Thirteenth 13日星期五
- USACO 1.1.3 Friday the Thirteenth
- 【USACO1.1_3】★Friday the Thirteenth 黑色星期五
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth (friday)
- 1.1.3 Friday the Thirteenth 黑色星期五
- USACO-Friday the Thirteenth(黑色星期五)-Section1.2<3>
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- [USACO 1.1.3] Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- (usaco) Friday the Thirteenth 黑色星期五
- OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五