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 ...
随机推荐
- Gradle是什么?
Gradle是什么? Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化构建工具.它使用一种基于Groovy的特定领域语言(DSL)来声明项目设置,抛弃了基于XML的 ...
- Python(一)list tuple dict set
这篇文章是为了复习之前学的python的数据结构: 原文链接:http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a ...
- 获取 input type=file 上次文件的路径
可以通过 $('这个元素').val();得到全路径:
- Django 单元测试笔记
引言 关于单元测试的基本知识这里不再讲述,简单一句话:单元测试是用一段代码去测试另一段代码.最常用的框架是unittest,这是python的单元测试框架,而django单元测试框架test.Test ...
- Vue中修改组件默认样式
vue 中直接使用 class 修改组件的默认样式,在使用 scoped 之后,样式是没有效果. 此时可以使用div 包裹组件,deep 可以实现修改组件样式 .lxfix /deep/ .contr ...
- Linux中命令备份mysql形成文件
基于龙哥(Thomas)的总结: mysqldump -u 用户名 -p密码 数据库名>bbs87.sql | tar -zcvf bbs87.tar.gz bbs87.sql 通过词条命令可以 ...
- cf854B Maxim Buys an Apartment
Maxim Buys an Apartment #include <iostream> #define int long long using namespace std; int n,k ...
- JavaScript 闭包&基于闭包实现柯里化和bind
闭包: 1 函数内声明了一个函数,并且将这个函数内部的函数返回到全局 2 将这个返回到全局的函数内中的函数存储到全局变量中 3 内部的函数调用了外部函数中的局部变量 闭包简述: 有权访问另一个函数局部 ...
- JavaScript动画相关
JS动画原理 通过CSS缓慢变化从而实现动画效果 获取css属性 Window.getComputedStyle()方法返回一个对象,该对象在应用活动样式表并解析这些值可能包含的任何基本计算后报告元素 ...
- python脚本监听nginx是否运行
import sys import time import os import logging from logging.handlers import RotatingFileHandler imp ...