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 ...
随机推荐
- zeromq学习记录(六)C语言示例
考虑到官方的示例c语言是最多的 官方未使用C++语言演示的例子就使用VC编译C语言例子 记录在此 /************************************************** ...
- IIS7部署网站遇到的问题
1.web.config文件中更改配置项时: 因为 IIS 7 采用了更安全的 web.config 管理机制,默认情况下会锁住配置项不允许更改. 运行命令行 %windir%\system32\ ...
- ABP框架系列之十六:(Dapper-Integration-Dapper集成)
Introduction Dapper is an object-relational mapper (ORM) for .NET. Abp.Dapper package simply integra ...
- vi分屏指令
用vi打开,view打开vsplit不支持 命令模式下::new,新建文件并分屏, 快捷键,Ctrl+W,然后马上按n键:spilt 水平分屏,将当前屏分为两个,水平的. Ctrl + w, s: ...
- LVS、Nginx 及 HAProxy 工作原理
当前大多数的互联网系统都使用了服务器集群技术,集群是将相同服务部署在多台服务器上构成一个集群整体对外提供服务,这些集群可以是 Web 应用服务器集群,也可以是数据库服务器集群,还可以是分布式缓存服务器 ...
- Catalan数与出栈顺序个数,Java编程模拟
问题描述: 队列中有从1到7(由小到大排列)的7个整数,问经过一个整数栈后,出栈的所有排列数有多少?如果整数栈的容量是4(栈最多能容纳4个整数),那么出栈的排列数又是多少? 分析:对于每一个数字i, ...
- hdu 1325 && poj 1308 Is It A Tree?(并查集)
Description A tree is a well-known data structure that is either empty (null, void, nothing) or is a ...
- React Native桥接器初探
本文假设你已经有一定的React Native基础,并且想要了解React Native的JS和原生代码之间是如何交互的. React Native的工作线程 shadow queue:布局在这个线程 ...
- windows10环境下安装Tensorflow
1.什么是tensorflow TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理.Tensor(张量)意味着N维数组,Flow(流)意味着 ...
- Exception、Error、运行时异常与一般异常有何异同
转自博客 https://blog.csdn.net/m0_37531231/article/details/79502778 一.开场白 对于程序运行过程中的可能出现异常情况,java语言使用一种 ...