题意:

两个人轮流玩游戏,每个人可以把日期进行转移,转移规则:
1.可以转移到当前日期的下一天。
2可以转移到下个月的这一天。(但是如果下个月没有这一天就不能进行第二种转移)
3.如果A恰好移动到2001.11.4那么A赢,如果移动到2001.11.4之后则输给你初始日期(只能在1900.1.1~2001.11.4)求先移动的人的胜负态

题目:

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.

Input

The input consists of T test cases. The number of test cases (T ) is given in the first line of the input file. 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.

Output

Print 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

分析:

这是一条简单的规律:一般情况下,月份和日子同奇偶则必胜,否则必败;只有9月30和11月30是例外。

有31天的月份:1,3,5,7,8,10,12
30天的月份:4,6,9,11
奇葩月:2
(1).先从2001.11开始看,这个月只有4天,且每一天只有第一种转移态,那么可以知道1和3号是必胜态,2和4号是必败态,故2001.11月是奇胜
(2).再向前看10月,因为10.5~ 10.31的转移态只有第一种转移态,那么根据推断,10.31为必败,所以5 ~ 31的这些天里偶数的天为必胜态,奇数必败。再看10月的1 ~ 4,对于4来说下一个可以到5和11.4,所以必胜,对于3可以到11.3和10.4所以必败,所以1~4也是偶数必胜奇数必败,故10月是偶数必胜,奇数必败。
(3).再看9月,因为9.30可以转到10.1和10.30,为了胜利就选择到10.1故9.30必胜,然后看9.29,可以转到10.29和9.30,同样为了胜利转到10.29,但是再看9.28,无论转到9.29还是10.28都会输,所以9.28是必败,同理9月的1~ 27都是奇胜偶败,加上28,29,30可以得出结论,9月的1~29号都是奇胜偶败,且9.30也为胜。
(4).再看八月,8.31只能到9.1,故为败,8.30可以到8.31故为胜,8.29可以到9.29和8.30,而这两种都会输,所以8.29是输,则1~28号的推理过程相似所以8月是奇败偶胜。
这样可以按照相同的方法推出:
(5).7月:奇胜偶败
。。。。。。。
3月:奇胜偶败
再来看2月,如果有29天,则对于2.29可以到3.29和3.1,都会输,所以2.29败,2.28可以到2.29故会赢。所以这种情况是奇败偶胜
如果只有28天,2.28可以到3.28故会赢,2.27可以到2.28和3.27,但都会输,所以这种情况是奇败偶胜
所以2月无论是有29天还是有28天都是奇败偶胜
1月:奇胜偶败
前一年:
12月:奇败偶胜
11月:30可以到12.1,所以胜利,29可以到12.29所以胜利,28可以到29和12.28,但是都会输,所以11月的1~29都是奇胜偶败,且30也会胜利
所以对于任意一个日期(除了9.30和11.30)只要月份+天数为偶数就会胜利,否则失败。

AC代码:

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int t,n,m,k;
int main(){cin>>t;while(t--){cin>>n>>m>>k;if(m==9&&k==30||m==11&&k==30)cout<<"YES"<<endl;else if((m+k)%2==0)cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}

Calendar Game POJ - 1082(关于日历的博弈问题)相关推荐

  1. python输出日期语句_python使用calendar输出指定年份全年日历的方法

    python使用calendar输出指定年份全年日历的方法 本文实例讲述了python使用calendar输出指定年份全年日历的方法.分享给大家供大家参考.具体实现方法如下: import calen ...

  2. 梅花雪Web Calendar ver 3.0 网页日历在asp.net 2.0的应用

    在.net中使用此控件,需要做些修改,经实验仅保留最佳方案,步骤如下: 1.   <script type="text/javascript" src= "../J ...

  3. 博弈最高位POJ 1704(Georgia and Bob-Nim博弈)

    新手发帖,很多方面都是刚入门,有错误的地方请大家见谅,欢迎批评指正 Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Su ...

  4. ASP.NET 在vs中使用Calendar控件 制作一个日历 并标注节假日

    Calendar控件 Calendar控件可以说用户方便.准确地选择日期或查看与日期相关的数据.当创建Calendar控件中的每个日期单元格均会引发DayRender事件,通过DayRender事件的 ...

  5. POJ - 2348 Euclid's Game(博弈)

    题目链接:点击查看 题目大意:给出初始的两个数字,每一次操作都要在规则下进行:令较大的数减去任意倍较小的数,必须保证不能出现负数,先减到零者获胜,问谁能获胜 题目分析:这个题目说是博弈我感觉更像是找规 ...

  6. poj 1067 取石子游戏(博弈+威佐夫博奕(Wythoff Game))

    取石子游戏 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29959   Accepted: 9818 Descriptio ...

  7. python输入年份打印全年日历_python使用calendar输出指定年份全年日历的方法

    {"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],&q ...

  8. WPF 4 日历控件(Calendar)

    WPF 4 日历控件(Calendar) 原文:WPF 4 日历控件(Calendar) 在之前我已经写过两篇关于WPF 4 任务栏(Taskbar)相关的特性.相信自从VS2010 Beta 版放出 ...

  9. 2019日历全年一张_python 日历模块calendar

    calendar #打印2019年的日历x= calendar.calendar(2019)print(x) #打印全年日历 calendar.prcal(2019) # 打印月份 c = calen ...

最新文章

  1. mysql 单标递归_MySql整理篇之递归
  2. sql server2005 常用语句
  3. 第一周周日DailyReporting——PM(李忠)
  4. HDU 1754 I Hate It 线段树
  5. textedit实时显示位置_加什么地形就看什么等高线!等高线实时预览就是这么爽...
  6. HBase流量限制和表负载均衡剖析
  7. 构造函数和方法的区别
  8. Cent OS 6.X 开机错误修复
  9. DB2事务日志使用经验
  10. 设计模式17---设计模式之模板方法模式(Template Method)(行为型)
  11. 独热向量编码(one-hot encoding)原理详解与实现
  12. (三)mybatisPlus自定义Sql语句
  13. 搭建WEB服务器及常见端口扫描工具分享
  14. 轻量级linux桌面环境,Linux发行版最为轻量级的桌面环境之一Xfce 桌面
  15. 深入ReentrantLock底层原理01
  16. 基于LabVIEW的计时器
  17. 已毕业学生的一些建议
  18. eclipes和idea常用快捷键及缩写大全
  19. 基于 GitLab CI 的前端工程CI/CD实践
  20. 计算机中什么符号代表除号,电脑怎么打除号?word除号怎么打出来?键盘上÷号是哪个键?除以符号电脑怎么打?...

热门文章

  1. Android之解决Base64 encode中文乱码问题
  2. LeetCode之Nim Game
  3. C++之类模板最简单的使用
  4. es mysql 同步插件_[es和数据库怎么同步]mysql与elasticsearch实时同步常用插件及优缺点对比(ES与关系型数据库同步)...
  5. 导出jar插件_Fluttify输出的Flutter插件工程详解
  6. 轮子一定要是圆的吗?
  7. 假期别在家里要发霉了?可以靠他们度过无聊时光
  8. 每日一笑 | 程序员的招租公告
  9. 进军人工智能,数学基础很重要?
  10. 10G 职场晋升/IT干货/生活技能/理财秘籍 【全套】学习资料免费送!