题目大意

给定 $n$($1\le n\le 24$)个正整数 $a_1,\dots, a_n$ 判断 $a_1$ 到 $a_n$ 是否可能为连续 $n$ 个月份的天数。

解法

由于 $n\le 24$,这 $n$ 个月包含在至多 3 年内,而三年的可能情况有:
闰年—平年—平年
平年—闰年—平年
平年—平年—闰年
平年—平年—平年

将这四种模式合并起来:
平年—平年—平年—闰年—平年—平年

将输入月份序列在上述模式中做匹配。

比赛时我的错误做法

没有考虑到这些月份可能包含在 3 年内,误认为包含在至多两年内,故而我采用的模式为:
平年—闰年—平年—平年

Codeforces 899B Months and Years的更多相关文章

  1. Codeforces Round #452 (Div. 2)-899A.Splitting in Teams 899B.Months and Years 899C.Dividing the numbers(规律题)

    A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. Codeforces 899 B.Months and Years

    B. Months and Years   time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. 【Codeforces Round #452 (Div. 2) B】Months and Years

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 闰,平,平 平,闰,平 平,平,闰 平,平,平 4种情况都考虑到就好. 可能有重复的情况. 但是没关系啦. [代码] #includ ...

  4. codeforces 724

    题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory ...

  5. [codeforces 260]B. Ancient Prophesy

    [codeforces 260]B. Ancient Prophesy 试题描述 A recently found Ancient Prophesy is believed to contain th ...

  6. Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理

    D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/probl ...

  7. Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题

    C. Four Segments 题目连接: http://codeforces.com/contest/14/problem/C Description Several months later A ...

  8. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  9. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. 使用ABAP代码返回S/4HANA Material上维护的Attachment明细

    在事务码 MM02里为ID为16的material维护附件: 如何使用ABAP代码获得如下附件的名称和文件内容? REPORT zgos_api. DATA ls_appl_object     TY ...

  2. 【转】 iOS学习之NSBundle介绍和使用

    bundle是一个目录,其中包含了程序会使用到的资源.这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in).对应bundle, cocoa提供了类NSBun ...

  3. Python-OpenCV——Image inverting

    通常我们将读入的彩色图转化成灰度图,需要将灰度图反转得到掩码,如何正确快速的得到某个图像的反转图呢? 首先看一种看似很正确的写法,对其中每个像素进行如下处理: img[x,y] = abs(img[x ...

  4. 为DataGridView控件实现复选功能

    实现效果: 知识运用: DataGridViewCheckBoxColumn类 实现代码: private class Fruit { public int Price { get; set; } p ...

  5. PAT (Basic Level) Practise (中文)- 1012. 数字分类 (20)

    http://www.patest.cn/contests/pat-b-practise/1012 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数 ...

  6. Flash as3.0 保存MovieClip运动轨迹到json文件

    //放在第一帧调用 import flash.events.Event; import flash.display.MovieClip; stage.addEventListener(Event.EN ...

  7. d3.js--03(增删改查)

    选择元素 d3.select():是选择所有指定元素的第一个 d3.selectAll():是选择指定元素的全部 插入元素 append():在选择集末尾插入元素 insert():在选择集前面插入元 ...

  8. python--以1-31的数字作为结尾的列表?论英文好的重要性!

    一.python基础教程第2板(修订版)[代码清单2-1]中有一段要求打印‘以1-31的数字作为结尾的列表’ 截取代码示例:endings =['st','nd','rd'] +17*['th'] + ...

  9. asp发送短信验证码 pst方式

    <script language="jscript" runat="server">  Array.prototype.get = function ...

  10. mysql替换表中某字段的某值

    UPDATE  `cases`  SET  `case_desc` = replace(`case_desc`, 'src="//tuku-assets.m.jia.com/assets/i ...