[模拟]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 ...
随机推荐
- win10 uwp 打开文件管理器选择文件
本文:让文件管理器选择文件,不是从文件管理器获得文件. 假如已经获得一些文件,那么如何从文件管理器选择这些文件? 使用方法很简单. 从网上拿图来说 打开文件夹自动选择所有文件 首先需要获得文件夹,因为 ...
- OpenWRT UCI命令实现无线中继
本文主要功能主要是利用OpenWRT系统uci命令实现无线中继,主要是利用uci程序修改/etc/congfig/目录下的配置文件.实现步骤如下主要分为以下几步: 1) 安装 relayd (opkg ...
- UVa11054
一开始WA了一次,这才反应过来应该用longlong而不是int,但是scanf和printf不知道哪出毛病了,运行不出来正确的结果,改成cin cout过了 从左向右扫描即可,对于第i的村庄到第i+ ...
- java选择结构
/**选择结构*/ public class Demo06{ public static void main(String []args){ // if...else...型 String name ...
- LeetCode 624. Maximum Distance in Arrays (在数组中的最大距离)$
Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from t ...
- 在windows下,将mysql离线数据文件导入本地mysql数据库
1. 查看mysql路径 SELECT @@basedir AS basePath FROM DUAL 其实mysql5.6 的数据文件在 C:\ProgramData\MySQL\MySQL Ser ...
- java语言编写杨辉三角
package com.llh.demo; /** * 杨辉三角 * * @author llh * */ public class Test { /* * 杨辉三角 */ public static ...
- (转)IDEA破解 2017 IDEA license server 激活(可用)
进入ide主页面,help-register-license server,然后输入 http://idea.iteblog.com/key.PHP(注意:php要小写)即可~
- Spring框架学习之高级依赖关系配置(二)
紧接着上篇内容,本篇文章将主要介绍XML Schema的简化配置和使用SpEL表达式语言来优化我们的配置文件. 一.基于XML Schema的简化配置方式 从Spring2.0以来,Spring支持使 ...
- jQuery点击下拉菜单的展示与隐藏
首先点击显示某个div,然后要求再次点击时消失,或者点击document的其他地方会隐藏掉这个层,涉及到冒泡的问题,阻止document冒泡到dom上.代码如下: var $el = $(" ...