P1202 [USACO1.1]黑色星期五Friday the Thirteenth
题目描述
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
说明
题目翻译来自NOCOW。
USACO Training Section 1.1
#include <cstdio>
#include <ctype.h>
#include <string>
#include <iostream>
#include <cstring>
#include <math.h>
#include <vector>
#include <queue>
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int year,last=,go,ans[];
int mouth[]={,,,,,,,,,,,,};
int n;
void pass(int nowyear)
{
for(int i=;i<=;i++)
{
int t=;
if(i==)
{
if(nowyear%&&nowyear%==)
t=;else
if(nowyear%==) t=;
}
go=(mouth[i]+t+last)%;
if(go==) last=;else
last=go;
ans[last]++;
}
}
int main()
{
scanf("%d",&n);
last=%;
ans[last]++;
for(int i=;i<n;i++)
pass(+i);
ans[last]--;
printf("%d ",ans[]);
printf("%d ",ans[]);
for(int i=;i<=;i++)
printf("%d ",ans[i]);
return ;
}
P1202 [USACO1.1]黑色星期五Friday the Thirteenth的更多相关文章
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
黑色星期五 难度:☆ Code: #include <iostream> #include <cstdio> #include <cstring> using na ...
- 洛谷P1202 [USACO1.1]黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- [模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth
原题 解析: 坑 其实.样例的部分是从周六~周五输出的,习惯不同吧..这里考虑到从这个月的13号到下一个月的13号所花天数为这个月的天数,然后愉快的判断一下闰年即可.这里的周一~周日编号为0~6,一月 ...
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth 题解
题目传送门 这道题暴力就能解决. #include<bits/stdc++.h> using namespace std; int xi; ,ans[]; int main() { int ...
- USACO Training Section 1.1黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- Luogu USACO Training 刷水记录
开个坑记录一下刷USACO的Training的记录 可能会随时弃坑 只有代码和做法简述 可能没有做法简述 [USACO1.1]你的飞碟在这儿Your Ride Is He… 模拟,细节已忘 #incl ...
- 【usaco】1.1
你的飞碟在这儿Your Ride Is Here(难度:入门难度) 题目链接 题目大意 emmmm 输入两个字符串,问他们每个字母的asco码相乘后字符串是否相等. 思路 一道水题?(雾) 错误代码: ...
- Friday the Thirteenth 黑色星期五 USACO 模拟 超级简单做法
1003: 1.1.3 Friday the Thirteenth 黑色星期五 时间限制: 1 Sec 内存限制: 128 MB提交: 8 解决: 8[提交] [状态] [讨论版] [命题人:外部 ...
- USACO-Friday the Thirteenth(黑色星期五)-Section1.2<3>
[英文原题] Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of t ...
随机推荐
- javascript之创建对象的方式
1.object构造函数创建 var obj=new Object(); obj.name='xue'; 2.对象字面量创建 var obj={ name:'xue' } 3.构造函数创建 funct ...
- JAVA 需要理解的重点 一
需要理解的重点内容有: JVM内存管理机制和垃圾回收机制(基本每次面试都会问,一定要搞得透彻) JVM内存调优(了解是怎么回事,一般做项目过程中使用较多) 设计模式(熟悉常见设计模式的应用场景,会画类 ...
- ubuntu12.04下有线网无电缆插入问题
解决方案: 1.查看是否没装网卡驱动: 2.检查网卡是否损坏: 3.检查网线是否损坏(注意:有时候不一定是网线损坏了,而是网线太细了,导通性不好.本人用细网线试了一下,windows下面可以连接网络, ...
- 20个jQuery分页插件和教程
1.客户端的jQuery 分页插件jPages jPages 是一个客户端的分页插件,但提供很多特性例如自动翻页.键盘和滚动浏览,延迟显示以及完全可定制的导航面板. Read More Demo 2. ...
- java 整除(/) 求余(%) 运算
1. java 整除(/) 求余(%) 运算 1.求余 System.out.println(11%2); //顾名思义就是11除2的余数-->1 System.out. ...
- 【219】◀▶ IDL 数学函数说明
参考:Math - Miscellaneous Routines参考:Math - Statistical Tools Routines 01 ABS 绝对值. 02 SQRT 平方根. 03 ...
- Hibernate使用Query进行查询
错误结果如下 Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: new ...
- DOM学习笔记(三)DOM元素的访问、修改与事件
访问 HTML 元素等同于访问节点,使用的是document对象下的数个getElement方法,然后再对返回的元素(或元素列表)进行具体内容的访问和修改,或者响应对应的事件是操作 一些 DOM 对象 ...
- 1004 Counting Leaves (30 分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family member ...
- Git之忽略提交 .gitignore
1.touch .gitignore 创建忽略文件,若此文件已存在,请忽略这一步 2.vi .gitignore 编辑忽略文件,将需要忽略的文件添加到忽略文件中 3.git status 发现忽 ...