题目描述

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.

输出格式:

输入输出样例

输入样例#1:

20
输出样例#1:

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的更多相关文章

  1. 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth

    黑色星期五 难度:☆ Code: #include <iostream> #include <cstdio> #include <cstring> using na ...

  2. 洛谷P1202 [USACO1.1]黑色星期五Friday the Thirteenth

    题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...

  3. [模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth

    原题 解析: 坑 其实.样例的部分是从周六~周五输出的,习惯不同吧..这里考虑到从这个月的13号到下一个月的13号所花天数为这个月的天数,然后愉快的判断一下闰年即可.这里的周一~周日编号为0~6,一月 ...

  4. 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth 题解

    题目传送门 这道题暴力就能解决. #include<bits/stdc++.h> using namespace std; int xi; ,ans[]; int main() { int ...

  5. USACO Training Section 1.1黑色星期五Friday the Thirteenth

    题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...

  6. Luogu USACO Training 刷水记录

    开个坑记录一下刷USACO的Training的记录 可能会随时弃坑 只有代码和做法简述 可能没有做法简述 [USACO1.1]你的飞碟在这儿Your Ride Is He… 模拟,细节已忘 #incl ...

  7. 【usaco】1.1

    你的飞碟在这儿Your Ride Is Here(难度:入门难度) 题目链接 题目大意 emmmm 输入两个字符串,问他们每个字母的asco码相乘后字符串是否相等. 思路 一道水题?(雾) 错误代码: ...

  8. Friday the Thirteenth 黑色星期五 USACO 模拟 超级简单做法

    1003: 1.1.3 Friday the Thirteenth 黑色星期五 时间限制: 1 Sec  内存限制: 128 MB提交: 8  解决: 8[提交] [状态] [讨论版] [命题人:外部 ...

  9. 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 ...

随机推荐

  1. WebApi发送HTML表单数据:文件上传与多部分MIME

    5.3 Sending HTML Form Data5.3 发送HTML表单数据(2) 本文引自:http://www.cnblogs.com/r01cn/archive/2012/12/20/282 ...

  2. JavaScript 日期处理类库 moment

    可以自定义自己需要的时间格式,中文文档如下: http://momentjs.cn/ http://momentjs.cn/docs/

  3. vue.js 组件共用函数的方法之一

    如果我现在写一个组件pullMore,想要用到loadMore里面的方法(函数), 那么只需要在当前组件pullMore,script里面先引入组件import loadMore from './lo ...

  4. centos7使用ceph-deploy部署ceph

    准备阶段 准备yum源 删除默认的源,国外的比较慢 yum clean all rm -rf /etc/yum.repos.d/*.repo 下载阿里云的base源 wget -O /etc/yum. ...

  5. bzoj3832

    拓扑排序+set 如果我们直接记录所有路径是不行的,那么我们要降低路径的数量,于是我们把最短路径转换到边上,这样我们就只有m条路径了. 先计算出f[i]和g[i]表示正反拓扑最长链,把所有g插到set ...

  6. js事件触发器fireEvent和dispatchEvent

    转自:https://www.cnblogs.com/tiger95/p/6962059.html 事件触发器就是用来触发某个元素下的某个事件,IE下fireEvent方法,高级浏览器(chrome, ...

  7. CF-831C

    C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  8. A - Vasya and Socks

    A - Vasya and Socks Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64 ...

  9. 将java项目打包成jar包,之后在制作成可执行的exe文件

    1.利用eclipse选择 2.利用ex4j,详情见百度教程http://jingyan.baidu.com/article/00a07f38aad55182d128dc4c.html

  10. vsftpd总结

    1 vsftps配置文件详解 (1)/user/sbin/vsftpd  主程序 (2)/etc/rc.d/init.d/vsftpd 启动脚本 (3)/etc/pam.d/vsftpd (file= ...