Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they played the Calendar Game, in celebration of this contest. This game consists of the dates from January 1, 1900 to November 4, 2001, the contest day. The game starts by randomly choosing a date from this interval. Then, the players, Adam and Eve, make moves in their turn with Adam moving first: Adam, Eve, Adam, Eve, etc. There is only one rule for moves and it is simple: from a current date, a player in his/her turn can move either to the next calendar date or the same day of the next month. When the next month does not have the same day, the player moves only to the next calendar date. For example, from December 19, 1924, you can move either to December 20, 1924, the next calendar date, or January 19, 1925, the same day of the next month. From January 31 2001, however, you can move only to February 1, 2001, because February 31, 2001 is invalid.

A player wins the game when he/she exactly reaches the date of November 4, 2001. If a player moves to a date after November 4, 2001, he/she looses the game.

Write a program that decides whether, given an initial date, Adam, the first mover, has a winning strategy.

For this game, you need to identify leap years, where February has 29 days. In the Gregorian calendar, leap years occur in years exactly divisible by four. So, 1993, 1994, and 1995 are not leap years, while 1992 and 1996 are leap years. Additionally, the years ending with 00 are leap years only if they are divisible by 400. So, 1700, 1800, 1900, 2100, and 2200 are not leap years, while 1600, 2000, and 2400 are leap years.

InputThe input consists of T test cases. The number of test cases (T) is given in the first line of the input. Each test case is written in a line and corresponds to an initial date. The three integers in a line, YYYY MM DD, represent the date of the DD-th day of MM-th month in the year of YYYY. Remember that initial dates are randomly chosen from the interval between January 1, 1900 and November 4, 2001. 
OutputPrint exactly one line for each test case. The line should contain the answer "YES" or "NO" to the question of whether Adam has a winning strategy against Eve. Since we have T test cases, your program should output totally T lines of "YES" or "NO". 
Sample Input

3
2001 11 3
2001 11 2
2001 10 3

Sample Output

YES
NO
NO 大意:

从当前日期,一个玩家在他可以移动到下一个日程表日期或下个月的同一天。当下个月没有同一天的时候,玩家只会移动到下一个日历日期。例如,从1924年12月19日,你可以移动到1924年12月20日,下一个日历的日期,或1925年1月19日,下一个月的同一天。但是,从2001年1月31日起,您只能移动到2001年2月1日,因为2001年2月31日是无效的。当一名选手正好到达2001年11月4日时,他就赢得了比赛。如果玩家移动到2001年11月4日之后,他就会输掉游戏。

思路:知道是找规律但是没看出来,搜题解后发现原来月加日期是偶数则赢,奇数则输,但是9.30和11.30也是赢的。当然还有一种方式就是打表。

AC Code:

#include<iostream>
using namespace std;
int main(){
int n,y,m,d;
cin>>n;
for(int i=;i<n;i++)
{
cin>>y>>m>>d;
if(m==&&d==||m==&&d==) cout<<"YES"<<endl;
else if((m+d)%==) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}

Calendar Game HDU - 1079的更多相关文章

  1. Day11-G - Calendar Game HDU - 1079

    Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they pl ...

  2. Hdu 1079 Calendar Game

    Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079 一道博弈题.刚开始想用判断P点和N点的方法来打表,但无奈不知是哪里出错,总是WA.于是 ...

  3. HDU 1079 Calendar Game(博弈找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每 ...

  4. HDU 1079 Calendar Game(简单博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. HDU 1079 Calendar Game (博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. HDU 1079 Calendar Game(规律博弈)

    题目链接:https://cn.vjudge.net/problem/HDU-1079 题目: Adam and Eve enter this year’s ACM International Col ...

  7. HDU 1079 Calendar Game (博弈论-sg)

    版权声明:欢迎关注我的博客,本文为博主[炒饭君]原创文章.未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/32336485 C ...

  8. hdu 1079 Calendar Game sg函数 难度:0

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  9. (step 8.2.8)hdu 1079(Calendar Game)

    题目大意是: 两个家伙在区域赛前夕闲的无聊,然后玩一种无限纠结的游戏,随即给定一个日期,每次只能移动day OR month.......... 而且如果下一个月没有当前day的话, 你就不能移动mo ...

随机推荐

  1. tp框架中的一些疑点知识-7

    mysqli是用面向对象的,所以用箭头对象语法, 而mysql是用C语言面向过程写的, 所以用的都是php全局函数 式的写法. tinkle: 叮叮当当的响; (口语)一次电话, i will giv ...

  2. P4568 [JLOI2011]飞行路线

    思路 套路题 建出k+1分层图,从上一层走到下一层代表坐了一次免费航线,跑最短路即可 注意可能有情况不需要耗完所有k次机会,所以应从每层的终点向下一层终点连一条边权为0的边 代码 #include & ...

  3. 论文阅读:CNN-RNN: A Unified Framework for Multi-label Image Classification

    CNN-RNN: A Unified Framework for Multi-label Image Classification Updated on 2018-08-07 22:30:41 Pap ...

  4. Java基础 【Arrays 类的使用】

    package com.zuoyan.sort; import java.util.Arrays; public class ArraysClassDemo { public static void ...

  5. redis事务之watch

    三.redis事务之watch 首先要了解redis事务中watch的作用,watch命令可以监控一个或多个键,一旦其中有一个键被修改(或删除),之后的事务就不会执行.监控一直持续到exec命令(事务 ...

  6. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]

    本文为博主原创,未经允许不得转载: 被坑了好长时间的bug,差点就要重新配置环境,重新下载,重新开始的境遇.在此记录一下: 首先展示一下报错的异常: -Apr- ::] org.apache.cata ...

  7. Katana的WebAPI集成Swagger 解决方案

    这位大哥写的博客很清楚了,我就不重复了. http://www.cnblogs.com/caodaiming/p/4156476.html 错误解决 http://blog.csdn.net/gold ...

  8. POJ 3126 Prime Path(素数路径)

    POJ 3126 Prime Path(素数路径) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 The minister ...

  9. AmazeUI学习

    http://amazeui.org/ 相比于其他国外的框架而言,Amaze UI更关注中文排版,被前端工程师称为最懂中文的前端框架. Amaze UI受欢迎的一个重要的原因是:文档非常完善,适合各阶 ...

  10. 【转】Windows Live Writer 代码插件改造

    源码和插件都在后面,如果不想看我神神叨叨的可以直接到文章后面下载 一 .找插件 在使用Windows Live Writer 经常要用到插入代码的功能,根据博客园中教程,分别使用了: WindowsL ...