USACO-Friday the Thirteenth(黑色星期五)-Section1.2<3>
【英文原题】
Friday the Thirteenth
Is Friday the 13th really an unusual event?
That is, does the 13th 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 13th 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.
Note that the start year is NINETEEN HUNDRED, not 1990.
There are few facts you need to know before you can solve this problem:
- January 1, 1900 was on a Monday.
- 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. - Every year evenly divisible by 4 is a leap year (1992 = 4*498 so
1992 will be a leap year, but the year 1990 is not a leap year) - The rule above does not hold for century years. Century years
divisible by 400 are leap years, all other are not. Thus, the century
years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap
year.
Do not use any built-in date functions in your computer language.
Don't just precompute the answers, either, please.
PROGRAM NAME: friday
INPUT FORMAT
One line with the integer N.
SAMPLE INPUT (file friday.in)
20
OUTPUT FORMAT
Seven space separated integers on one line. These integers represent the number of times the 13th falls on Saturday, Sunday, Monday, Tuesday, ..., Friday.
SAMPLE OUTPUT (file friday.out)
36 33 34 33 35 35 34
【中文翻译】
题目描述
13号又是一个星期五。13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数。给出N年的一个周期,要求计算1900年1月1日至1900+N-1年12月31日中十三号落在周一到周日的次数,N为正整数且不大于400.
这里有一些你要知道的:
1、1900年1月1日是星期一.
2、4,6,11和9月有30天.其他月份除了2月都有31天.闰年2月有29天,平年2月有28天.
3、年份可以被4整除的为闰年(1992=4*498 所以 1992年是闰年,但是1990年不是闰年).
4、以上规则不适合于世纪年。可以被400整除的世纪年为闰年,否则为平年。所以,1700,1800,1900和2100年是平年,而2000年是闰年.
请不要调用现成的函数
请不要预先算好数据(就是叫不准打表)!
输入输出格式
输入格式:
一个正整数n.
输出格式:
**输出请从周六开始
输入输出样例
20
36 33 34 33 35 35 34
#include<stdio.h>
bool isLeapYear(int year)//判断闰年
{
if(year == || year == || year == || year == || year == || year == || year == ){
if(year % == )
{
return true;
}
}
else if(year % == )
{
return true;//是闰年
}
return false;//不是闰年
}
int main(){
int n;
scanf("%d",&n);
int ans[] = {};
int day = ;
for(int i = ;i < + n;i++)
{
if(isLeapYear(i) == false)
{
for(int j = ;j < ;j++)
{//平年1月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年2月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年3月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年4月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年5月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年6月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年7月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年8月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年9月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年10月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年11月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//平年12月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
}
else{
for(int j = ;j < ;j++){//闰年1月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年2月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年3月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年4月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年5月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年6月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年7月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年8月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年9月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年10月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年11月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
for(int j = ;j < ;j++){//闰年12月
if(j == ){
if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}else if(day == ){
ans[day - ]++;
}
}
day++;
if(day > ){
day = ;
}
}
}
}
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("%d ",ans[]);
printf("\n");
return ;
}
USACO-Friday the Thirteenth(黑色星期五)-Section1.2<3>的更多相关文章
- Friday the Thirteenth 黑色星期五 USACO 模拟 超级简单做法
1003: 1.1.3 Friday the Thirteenth 黑色星期五 时间限制: 1 Sec 内存限制: 128 MB提交: 8 解决: 8[提交] [状态] [讨论版] [命题人:外部 ...
- USACO 1.1.3 Friday the Thirteenth 黑色星期五
Description 13号又是一个星期5.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至 ...
- JZOJ.1002【USACO题库】1.1.3 Friday the Thirteenth黑色星期五
每日一博第一天! 保持你的决心 题目描述 13号又是星期五是一个不寻常的日子吗? 13号在星期五比在其他日少吗?为了回答这个问题,写一个程序来计算在n年里13 日落在星期一,星期二......星期日的 ...
- USACO . Friday the Thirteenth
Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the mont ...
- USACO Section 1.1-3 Friday the Thirteenth
Friday the Thirteenth 黑色星期五 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数. 给出N年的一个 ...
- USACO/friday
Friday the Thirteenth 黑色星期五 描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的 ...
- USACO Section1.1 Friday the Thirteenth 解题报告
friday解题报告 —— icedream61 博客园(转载请注明出处) -------------------------------------------------------------- ...
- USACO Training Section 1.1黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- USACO Section1.2
section1.1主要包括四道题和两个编程知识介绍.下面将对这6个部分内容进行学习. Your Ride Is Here 这道题没什么难度,读懂题目意思就行:把两个字符串按照题目要求转换成数字,然后 ...
随机推荐
- 第11条:用zip函数同时遍历两个迭代器
核心知识点: (1)内置的zip函数可以平行地遍历多个迭代器. (2)python3中地zip相当于生成器,会在遍历过程中逐次产生元祖.而python2中地zip则是直接把这些元祖完全生成好,并一次性 ...
- eclipse 修改 JDK中的src.zip的路径
http://blog.sina.com.cn/s/blog_54a1bca7010112fb.html http://www.douban.com/note/211369821/ 1.点 “wind ...
- php 图片下载
php图片保存.下载 <?php //获取图片2进制内容 ,可以保存入数据库 $imgStr = file_get_contents('http://.../1.jpg'); //保存图片 $f ...
- HDU - 1114 Piggy-Bank 【完全背包】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1114 题意 给出一个储钱罐 不知道里面有多少钱 但是可以通过重量来判断 先给出空储钱罐的重量 再给出装 ...
- C#仿QQ设置界面导航
效果预览,选择左边标签,右边内容会自动滚动到适当位置 public class AnchorPanel { List<PanelMenu> lst = new List<PanelM ...
- NFS指定端口,NFS缓存
nfs服务端: #编辑/etc/nfsmount.conf,在末尾添加: #RQUOTAD_PORT=30001#LOCKD_TCPPORT=30002#LOCKD_UDPPORT=30002#MOU ...
- UI控件概述
常见UI控件 UIKit框架提供了非常多功能强大又易用的UI控件,以便于开发者打造出各式各样的App 以下列举一些在开发中常见的UI控件(稍后补上图片示例) 1.UILabel– 文本标签:作用是显示 ...
- ConcurrentHashMap以及HashMap,HashTable的区别
ConcurrentHashMap与HashMap,和HashTable 的区别? ConcurrentHashMap是一个线程安全的key-value数据结构,而HashMap不是.Concurre ...
- python ddt 重写
对此方法重写 def mk_test_name(name, value, index=0): 重写前 index = "{0:0{1}}".format(index + 1, in ...
- pyglet--EventLoop对象(主事件循环,用于从系统消息队列中取出消息,并派发给各个窗口)
一.识别系统消息,并派出该消息 EventLoop(应用程序的事件循环),用于循环的从系统消息队列中获取系统消息(包含消息的各种参数:如鼠标位置,事件类型,鼠标左右键,哪个键盘键等),然后派发相应的事 ...