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 如果要SG打表,对闰年的处理太困难,就需要忽略年份,那我们可以选择只考虑日期和月份,可以从奇偶性来考虑,先将日期转移情况列出来:
现在日期是(m, d)
1.日期加一 m+(d+1)
2.月份加一 (m+1)+d
3.到新的一个月 (m+1)+1
若m+d和为偶数时,操作1与2后和变为奇数,只满足操作3,不满足操作1、2的数对有(1,31)(3,31)(5,31)(8,31)(10,31),其中满足和为偶数的有(1,31)(3,31)(5,31),所以可以断言,所有和为偶数的数对都可以变成奇数
若m+d和为奇数时,操作1与2后和变为偶数,能满足操作3的数有(1,31)(2,28/29)(3,31)(4,30)(5,31)(6,30)(7,31)(8,31)(9,30)(10,31)(11,30)(12,31),其中和为奇数的有(2,29)(8,31)(9,30)(10,31)(11,30)(12,31),其中操作后为奇数的只有(9,30)(11,30)
已知目标状态为11+4=15,是奇数,那么,谁最终状态是奇数就必败,所以先手是偶数或者(9,30)(11,30)的时候就可以将奇数给后手,后手必定只能传递偶数回来,如果后手也拿到了(9,30)(11,30)呢?先手可以用最佳手段避开,两者的前者状态分别为(8,30)(9,29)(10,30)(11,29),这些都是偶数,可以有其他办法转移到其他奇数给后手
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL; void run_case() {
int year, month, day;
cin >> year >> month >> day;
if((month+day)%==||(month==&&day==)||(month==&&day==)) cout << "YES\n";
else cout << "NO\n";
} int main() {
ios::sync_with_stdio(false), cin.tie();
int t; cin >> t;
while(t--)
run_case();
cout.flush();
return ;
}
												

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

  1. Calendar Game HDU - 1079

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

  2. E - Tunnel Warfare HDU - 1540 F - Hotel G - 约会安排 HDU - 4553 区间合并

    E - Tunnel Warfare HDU - 1540 对这个题目的思考:首先我们已经意识到这个是一个线段树,要利用线段树来解决问题,但是怎么解决呢,这个摧毁和重建的操作都很简单,但是这个查询怎么 ...

  3. Hdu 1079 Calendar Game

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

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

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

  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 (博弈)

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

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

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

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

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

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

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

随机推荐

  1. 超好用的免费Redis客户端

    Redis这款基于内存的键值对(key-vlaue)数据库,自带了一个基于命令行式的管理工具redis-cli,但是使用起来并不方便.虽然现在有了许多的图形化管理工具,有些需要收费,有些不好用.最终还 ...

  2. python 读取一个文件夹下的所jpg文件保存到txt中

    最近需要使用统计一个目录下的所有文件,使用python比较方便,就整理了一下代码. import os def gci(filepath): files = os.listdir(filepath) ...

  3. 五、request模块

    描述:requests是python的一个第三方HTTP(Hypertext Transfer Protocol,超文本传输协议)库,它比python自带的网络库urllib更加简单.方便和人性化:使 ...

  4. 7,请描述下cookies,sessionStorage和localStorage的区别

    7,请描述下cookies,sessionStorage和localStorage的区别 首先,cookie是网站为了标识用户身份而储存在用户本地终端(client side,百科: 本地终端指与计算 ...

  5. c++高斯消元法求解线性方程组

    #include<iostream> #include<math.h> #include<string.h> using namespace std; #defin ...

  6. 常用的php函数

    最严格身份证号码验证,支持15位和19世纪出生的人的身份证号码 # 计算身份证校验码,根据国家标准GB 11643-1999 function idcard_verify_number($idcard ...

  7. SprintBoot学习(一)

    Spring Boot是什么? 1. SpringBoot是一个框架,一种全新的编程规范,他的产生简化了框架的使用,所谓简化是指简化了Spring众多框架中所需的大量且繁琐的配置文件,所以 Sprin ...

  8. 杭电 1114 Piggy-Bank 完全背包问题

    Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  9. 再次立个flag

    今天2019.9.18 从上次迷茫到现在,差不多过去快一年了.   准确点是 442 天 我顺便大概看了一下上次迷茫时期的日志,总觉的不可思议.上次是毕业大概几个月,到目前其实也没多久,但是我变了.. ...

  10. ES-基本操作

    (1)创建索引 put 192.168.247.197:9200/type2 /type2 (2)创建映射 post 192.168.247.197:9200/type2/type/_mapping ...