Day11-G - Calendar Game HDU - 1079
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的更多相关文章
- Calendar Game HDU - 1079
Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they pl ...
- E - Tunnel Warfare HDU - 1540 F - Hotel G - 约会安排 HDU - 4553 区间合并
E - Tunnel Warfare HDU - 1540 对这个题目的思考:首先我们已经意识到这个是一个线段树,要利用线段树来解决问题,但是怎么解决呢,这个摧毁和重建的操作都很简单,但是这个查询怎么 ...
- Hdu 1079 Calendar Game
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079 一道博弈题.刚开始想用判断P点和N点的方法来打表,但无奈不知是哪里出错,总是WA.于是 ...
- HDU 1079 Calendar Game(博弈找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每 ...
- HDU 1079 Calendar Game(简单博弈)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1079 Calendar Game (博弈)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1079 Calendar Game(规律博弈)
题目链接:https://cn.vjudge.net/problem/HDU-1079 题目: Adam and Eve enter this year’s ACM International Col ...
- HDU 1079 Calendar Game (博弈论-sg)
版权声明:欢迎关注我的博客,本文为博主[炒饭君]原创文章.未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/32336485 C ...
- hdu 1079 Calendar Game sg函数 难度:0
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
随机推荐
- list-style: none;
表明list项前面没有什么修饰(一片空白).
- thinkphp 3.2链接Oracle数据库,查询数据
ennnn,换工作了,开始用新的东西了,最近就是调用nc接口,数据库是Oracle,首先先把数据查出来,这个比较简单. 在网上看的其他的方法都是改数据库配置文件,然后需要修改tp核心的一个类文件,比较 ...
- wordpress Error establishing a database connection问题
最近这场大雨,快把帝都给淹了,我也快被这不定向问题折磨疯了,本来把项目放在A服务器,nginx ,php7,mysql,然后换到了B服务器,环境一模一样,结果呢,传上去就出现了 哎,话说我的配置也没啥 ...
- spring中@Component注解
1.@controller 控制器(注入服务) 2.@service 业务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到spr ...
- 1、安装GPIO Zero(Installing GPIO Zero)
学习目录:树莓派学习之路-GPIO Zero 官网地址:http://gpiozero.readthedocs.io/en/stable/installing.html 环境:UbuntuMeta-1 ...
- Servlet_001 我的第一个servlet程序
今天开启servlet学习 一.第一个Servlet程序 首先写我们的第一个servlet程序 第一步:新建我们的servlet程序(Web Project),命名为Servlet_001 第二步 : ...
- Go语言基础之Path包与FilePath包
文章引用自 path包的使用 package main; import ( "fmt" "path" ) //go语言path包的学习 func main() ...
- dfs(迷宫)
问题 J: 棋盘行走 时间限制: 1 Sec 内存限制: 128 MB[命题人:admin] 题目描述 小Biu在玩一个棋盘游戏,这个游戏给出一个n*m的棋盘,并且每个点上有一个棋子,棋子的颜色 用 ...
- 洛谷 P2118 比例简化(枚举)
嗯... 题目链接:https://www.luogu.org/problem/P2118 这道题的出题人很善良,l的范围不是很大,所以我们可以逐一枚举. 本题主要思想就是把所有的比例都转换为乘积的形 ...
- python函数1_参数,返回值和嵌套
函数 将重复的代码,封装到函数,只要使用直接找函数 函数可以增强代码的模块化和提高代码的重复利用率 函数的定义和调用 格式 def 函数名([参数,参数...]): 函数体 定义函数 import r ...