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 ...
随机推荐
- 日期格式在ios中的兼容性
在IOS中支持 2017/3/2 这种格式的日期 不支持2017-3-2日期 /** * 返回兼容ios.android的日期时间格式 * @param dateTime String * @retu ...
- easyExcel+poi导出Excel出现乱码
这种问题肯定是浏览器编码问题,修改官方给的util就好了
- re模块、正则表达式
一.正则表达式 1.正则表达式不是Python独有的,它是一门独立的技术,所有的编程语言都可以使用正则表达式,在Python中使用正则表达式就要借助于re模块,或者是支持正则表达式书写的方法. 2.用 ...
- plupload上传视频插件jQuery+php
我在网上找到一个很好的视频上传插件,经过我的一些整理.补充,在这里分享给大家. 这个视频插件是新浪微博plupload上传视频插件,支持格式有mpg,m4v,mp4,flv,3gp,mov,avi,r ...
- Yii2.0 连接数据库
打开数据库配置文件common\config\main-local.php
- JZOJ5915 [2018NOIP模拟] 明日之星(广义后缀自动机,线段树)
题目描述 给定一棵树,每个节点有一个权值 \(a_i\) 和一个字符串 \(s_i\). q组询问,每次询问一个字符串 S 和两个节点x,y: 求x到y路径上每个节点的字符串在 S 中出现的次数乘上各 ...
- HBase的完全分布式搭建
一.HBase的安装模式 ①单机安装:不依赖于Hadoop的HDFS,配置完即可使用,好处是便于测试,坏处是不具备分布式数据存储的能力. ②伪分布式安装:单台主机模拟真实环境. ③完全分布式安装:多台 ...
- C语言-switch语句的使用。对文件的输出处理。for循环和if的结合使用。
//函数fun功能:统计字符串中各元音字母的个数,注意:不区分大小写. //重难点:switch语句的使用. #include <stdlib.h> #include <conio. ...
- Windows Server 2012 R2 自动映射公共网络驱动器
1.创建组织单位,在组织单位新建用户或者组 2.新建文件夹(名字无所谓,我这里起名一样方便测试) 3.对文件夹开启共享,设置要共享的用户或者组 4.打开组策略,找到对应的组织单位 5.创建GPO 6. ...
- PHP的isset(),is_null,empty()你了解了没?
这几个变量判断函数在PHP开发中用的其实挺多的,而且粗看上去都差不多,但其实还是有不少的区别的,如果搞不清楚,也许就会遗留一些潜在的bug, 包括我自已也遇到过这样的坑,比如有一次我就遇到过用empt ...