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. Ubuntu package system is broken

    原文链接安装软件的时候出现错误,遇到包管理系统损坏的问题.在askubuntu上找到解决办法,这里进行记录总结:首先:sudo apt-get -f install 强制安装没有下载完成的文件.然后: ...

  2. 终于明白vim 和 grep 中 的正则表达式的用法, vim 正则表达式 和grep基本正则表达式 几乎一样

    要搞清楚 vim中的正则和普通的Perl正则表达式的区别: 因为在perl中所有的元字符 都可以直接使用, 不需要在 元字符的前面加 反斜杠. 但是在vim, 包括grep中就有所区别, 同样是元字符 ...

  3. 图片处理工具类 util

    PathUtil package util; public class PathUtil { private static String seperator = System.getProperty( ...

  4. Java 字符串拆分(拆分字符串)

    String sourceStr = "1,2,3,4,5"; String[] sourceStrArray = sourceStr.split(","); ...

  5. 集合04_Set

    Set集合总览 集合元素无序.不重复,三个实现类都是线程不安全的,最好在创建时通过Collections工具类的synchronizedSortedSet方法来包装Set集合,防止对set集合的意外非 ...

  6. C# DateTime判断时间

    两种情况: 1 DateTime? dtTemp = null; if(dtTime != null) { //wawawa } 刚刚学会的,可空值类型,可判断是否赋值 2 DateTime dtTe ...

  7. 论文笔记:Learning Dynamic Memory Networks for Object Tracking

    Learning Dynamic Memory Networks for Object Tracking  ECCV 2018Updated on 2018-08-05 16:36:30 Paper: ...

  8. Kubernetes之总体了解

    Kubernetes:架构.基本概念.用于总体了解 Kubernetes系列之介绍篇:优势.用途 Kubernetes核心概念总结

  9. P1230 智力大冲浪

    题目描述 小伟报名参加中央电视台的智力大冲浪节目.本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元.先不要太高兴!因为这些钱还不一定都是你的?!接下来主持人宣布了比赛规则: ...

  10. PyEngine3D

    git clone https://github.com/ubuntunux/PyEngine3D cd PyEngine3D pip install -r requirements.txt pyth ...