[模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth
原题
解析:
坑
其实。样例的部分是从周六~周五输出的,习惯不同吧。。这里考虑到从这个月的13号到下一个月的13号所花天数为这个月的天数,然后愉快的判断一下闰年即可。这里的周一~周日编号为0~6,一月到十二月的编号为0~11(方便计算)。。而且1900/1/13是周六
代码:知道我写得垃圾
#include<cstdio>
struct date {int yy,mm,ww;};
bool operator<(const date &a,const date &b) {
if(a.yy!=b.yy) return a.yy<b.yy;//日期比较
if(a.mm!=b.mm) return a.mm<b.mm;
return 0;
}
int d[2][13]= {31,28,31,30,31,30,31,31,30,31,30,31,0,31,29,31,30,31,30,31,31,30,31,30,31,0};
void operator++(date &a) {
bool spl=0;//是否闰年
if(!(a.yy%400)) spl=1;
if((a.yy%100)&&!(a.yy%4)) spl=1;
a.ww+=d[spl][a.mm++],a.ww%=7;
if(a.mm==12) a.yy++,a.mm=0;
}
int main() {
int n,t[7]={0};
scanf("%d",&n);
date a=(date) {1900,0,5};//起始时间
date b=(date) {1900+n-1,11,-1};//终止时间
while(!(b<a)) t[a.ww]++,++a;//过程
for(int i=5; i<12; i++) printf("%d ",t[i%7]);//输出
return 0;
}
[模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth的更多相关文章
- 洛谷P1202 [USACO1.1]黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
黑色星期五 难度:☆ Code: #include <iostream> #include <cstdio> #include <cstring> using na ...
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth 题解
题目传送门 这道题暴力就能解决. #include<bits/stdc++.h> using namespace std; int xi; ,ans[]; int main() { int ...
- P1202 [USACO1.1]黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- 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 ...
随机推荐
- Microsoft Offce 使用纪事:oneNote笔记本分区删除
OneNote 笔记本和分区删除 OneNote 目前无法在客户端和本地删除已有的笔记本和分区,只能通过OneDrive才能够从云端删除: step1 step2 step3 后记 由于需要登录One ...
- ubuntu6.04下安装Eclipse for C/C++ Development
ubuntu6.04下安装Eclipse for C/C++ Development 首先安装gcc/g++ 需要安装jdk,有的可以尝试安装openjdk. sudo apt-get install ...
- 基于HTML5的WebGL实现json和echarts图表展现在同一个界面
突然有个想法,如果能把一些用到不同的知识点放到同一个界面上,并且放到一个盒子里,这样我如果要看什么东西就可以很直接显示出来,而且这个盒子一定要能打开.我用HT实现了我的想法,代码一百多行,这么少的代码 ...
- Entity Framework Core 2.0 使用入门
一.前言 Entity Framework(后面简称EF)作为微软家的ORM,自然而然从.NET Framework延续到了.NET Core.以前我也嫌弃EF太重而不去使用它,但是EF Core(E ...
- 为Android设备添加A2SD支持
相信很多用Android设备的用户都有这个问题,内部存储太小导致应用只能装那么几个,虽然rom也有提供移动到sd卡的选项,但是仅仅是移动程序文件到sd卡,并不能解决多少问题,多装几个还是会 ...
- [Linux 使用(2)] 64位Linux下安装jboss-as-7.1 以及jdk1.7
一.软件的下载 jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.h ...
- 自学LinkedBlockingQueue源码
自学LinkedBlockingQueue源码 参考:http://www.jianshu.com/p/cc2281b1a6bc 本文需要关注的地方 生产者-消费者模式好处: 读取和插入操作所使用的锁 ...
- Asp.net Api中使用OAuth2.0实现“客户端验证”
一.实现继承自OAuthAuthorizationServerProvider的类,实现以"客户端验证"方式传入的相关认证和access_token发放. public class ...
- iOS 之 UITextField
UITextField 相关细节处理: 1. 设置leftView , rightView let leftView = UIView() // 设置leftView/rightView之后,勿忘设 ...
- JSON.stringify实战用法
1.首先定义一个数组 var teamPlanMinList = new Array(); 2. 定义一个json对象 var json = { "plname":plname, ...