HDU 1079 Calendar Game(规律博弈)
题目链接:
https://cn.vjudge.net/problem/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.
(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 解题思路:
已知两个人的博弈方式只能是days+1或者month+1,可得days+month之和总是在奇数和偶数之间变换,所以目标是取到11+4为奇数,那就必须要面对偶数才能赢。所以当给出的日期是偶数时,先手必赢,奇数时,先手必输,不过有两个特例是,9.30和11.30,他们是奇数,但是他们的两个后继有一个是还是奇数,能造成先手还是面临偶数,所以也行。
#include<cstdio> int main()
{
int T;
scanf("%d", &T);
int y, m, d;
while(T--){
scanf("%d%d%d", &y, &m, &d);
if((m + d) % == || (d == ) && (m == || m == ))
printf("YES\n");
else
printf("NO\n");
}
return ;
}
HDU 1079 Calendar Game(规律博弈)的更多相关文章
- 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 博弈
题目大意:从1900年1月1日 - 2001年11月4日间选择一天为起点,两个人依次进行两种操作中的任意一种,当某人操作后为2001年11月4日时,该人获胜.问先手是否获胜 操作1:向后移一天 操作2 ...
- HDU 1079 Calendar Game (博弈或暴搜)
题意:给定一个日期,然后 A 和 B 双方进行操作,谁先把日期变成2001年11月04日,将获胜,如果超过该日期,则输了,就两种操作. 第一种:变成下一天,比如现在是2001.11.3 变成 2001 ...
- Hdu 1079 Calendar Game
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079 一道博弈题.刚开始想用判断P点和N点的方法来打表,但无奈不知是哪里出错,总是WA.于是 ...
- 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 ...
- (step 8.2.8)hdu 1079(Calendar Game)
题目大意是: 两个家伙在区域赛前夕闲的无聊,然后玩一种无限纠结的游戏,随即给定一个日期,每次只能移动day OR month.......... 而且如果下一个月没有当前day的话, 你就不能移动mo ...
随机推荐
- trinitycore 魔兽服务器源码分析(二) 网络
书接上文 继续分析Socket.h SocketMgr.h template<class T>class Socket : public std::enable_shared_from_t ...
- addEventListener()方法
★JS事件的捕获阶段和冒泡阶段: 讨论的主要是两个事件模型:IE事件模型与DOM事件模型 IE内核浏览器的事件模型是冒泡型事件(没有捕获事件过程),事件句柄的触发顺序是从ChildNode到Paren ...
- 将JSON数据转换成JAVA的实体类
思路:首先将JSON格式的数据转换成JSONObject,然后将JSONObject转换成Java的实体类(其中类属性包括List等类型) Java实体类: SearchFilter 类 1 publ ...
- tabel表格的dom操作
对table表格的操作比较麻烦,一直字符串的连接会比较麻烦 var nod = cwgk_msg_list.insertRow();//这个是上边获取过的dom元素,一般是tbody的元素,对元素进行 ...
- 【repost】JavaScript 基本语法
JavaScript 基本语法,JavaScript 引用类型, JavaScript 面向对象程序设计.函数表达式和异步编程 三篇笔记是对<JavaScript 高级程序设计>和 < ...
- MFC文件IO和串行化
一. MFC中CFile对象实现了磁盘文档的读写,但是大部分MFC应用程序的IO服务都使用CArchive对象来完成.不管CFile和Archive输入输出的都是二进制数据,非文本数据. int a ...
- 消息中间件——activeMQ
Activemq使用教程 解压activmq进入bin\win64 启动activemq.bat 启动成功 浏览器访问http://127.0.0.1:8161 创建maven工程 在pom.xml中 ...
- nova scheduler filters 配置
scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler scheduler_default_filters = Avail ...
- a标签嵌套a标签在实际项目开发中遇到的坑
大家都知道HTML的嵌套规范,其中一个规范是块元素嵌套行内元素,块元素嵌套块元素,行内元素嵌套行内元素,行内元素不能嵌套块元素. 其中需要注意的是行内元素嵌套行内元素,a标签虽然是行内元素,但是a标签 ...
- [CocoaPods]CocoaPods安装详解
安装CocoaPods之前先安装ruby: 1.安装ruby ruby官网rubygems.org已被屏蔽,替换当前镜像是否为国内镜像. $gem sources --add https://gems ...