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 ...
随机推荐
- 操作系统学习笔记(三) windows内存管理
//系统物理页面是由 (Page Frame Number Database )简称PFN数据库来进行管理,实际上是一个数组,每个物理页面都对应一个PFN项. 进程的地址空间是通过VAD(Virtua ...
- mysql error#1251客户端版本过低
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 ...
- 《C#从现象到本质》读书笔记(八)第10章反射
<C#从现象到本质>读书笔记(八)第10章反射 个人感觉,反射其实就是为了能够在程序运行期间动态的加载一个外部的DLL集合,然后通过某种办法找到这个DLL集合中的某个空间下的某个类的某个成 ...
- 安装及使用virtualenv
安装tensorflow之virtualenv 在安装之前首先保证ubuntu.python,以及一些相应的包安装成功. 1.安装virtualenv#(1) pip $ sudo apt-get i ...
- ManageEngine SeviceDesk Plus帮助台和资产管理软件
- vue使用路由跳转到上一页
this.$router.go(-1) <template> <div> <button class="btn btn-success" @click ...
- 自动化部署shell
yum install curl policycoreutils openssh-server openssh-clients postfix [root@linux-node2 ~]# yum in ...
- 11g统计信息自动收集任务
1.查看统计信息自动收集任务的开启情况. select client_name,status from dba_autotask_client; 2.查看自动收集任务各个窗口的开启情况. col op ...
- 去除swagger ui的红色 error 错误提示
去除swagger ui的红色 error 错误提示 自定义js文件中加入以下的代码. 加入自定义的js方法看这里 http://www.cnblogs.com/wang2650/archive/20 ...
- hadoop安装hive及java调用hive
1.安装hive 在安装hive前,请确保已经安装好了hadoop,如未安装,请参考centoos 安装hadoop集群进行安装: 1.1.下载,解压 下载hive2.1.1:http://mirr ...