题目链接:
https://cn.vjudge.net/problem/HDU-1079

题目:

Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they played the Calendar Game, in celebration of this contest. This game consists of the dates from January 1, 1900 to November 4, 2001, the contest day. The game starts by randomly choosing a date from this interval. Then, the players, Adam and Eve, make moves in their turn with Adam moving first: Adam, Eve, Adam, Eve, etc. There is only one rule for moves and it is simple: from a current date, a player in his/her turn can move either to the next calendar date or the same day of the next month. When the next month does not have the same day, the player moves only to the next calendar date. For example, from December 19, 1924, you can move either to December 20, 1924, the next calendar date, or January 19, 1925, the same day of the next month. From January 31 2001, however, you can move only to February 1, 2001, because February 31, 2001 is invalid.

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 解题思路:

  已知两个人的博弈方式只能是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(规律博弈)的更多相关文章

  1. HDU 1079 Calendar Game(博弈找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每 ...

  2. HDU 1079 Calendar Game(简单博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. HDU 1079 Calendar Game (博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. HDU 1079 Calendar Game 博弈

    题目大意:从1900年1月1日 - 2001年11月4日间选择一天为起点,两个人依次进行两种操作中的任意一种,当某人操作后为2001年11月4日时,该人获胜.问先手是否获胜 操作1:向后移一天 操作2 ...

  5. HDU 1079 Calendar Game (博弈或暴搜)

    题意:给定一个日期,然后 A 和 B 双方进行操作,谁先把日期变成2001年11月04日,将获胜,如果超过该日期,则输了,就两种操作. 第一种:变成下一天,比如现在是2001.11.3 变成 2001 ...

  6. Hdu 1079 Calendar Game

    Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079 一道博弈题.刚开始想用判断P点和N点的方法来打表,但无奈不知是哪里出错,总是WA.于是 ...

  7. HDU 1079 Calendar Game (博弈论-sg)

    版权声明:欢迎关注我的博客,本文为博主[炒饭君]原创文章.未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/32336485 C ...

  8. hdu 1079 Calendar Game sg函数 难度:0

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  9. (step 8.2.8)hdu 1079(Calendar Game)

    题目大意是: 两个家伙在区域赛前夕闲的无聊,然后玩一种无限纠结的游戏,随即给定一个日期,每次只能移动day OR month.......... 而且如果下一个月没有当前day的话, 你就不能移动mo ...

随机推荐

  1. c++沉思录 学习笔记 第六章 句柄(引用计数指针雏形?)

    一个简单的point坐标类 class Point {public: Point():xval(0),yval(0){} Point(int x,int y):xval(x),yval(y){} in ...

  2. 深入理解JVM(五)JVM优化策略

    5.2一些案例: 1.高性能硬件部署策略: (1)背景:某公司升级了硬件(CPU升级为4核,内存增加为16G),发现不定期出现网页失去响应. (2)原因:①内存增加之后,项目中有在内存中处理文件的大对 ...

  3. 【APP测试(Android)】--功能

  4. 2019.02.11 bzoj4818: [Sdoi2017]序列计数(矩阵快速幂优化dp)

    传送门 题意简述:问有多少长度为n的序列,序列中的数都是不超过m的正整数,而且这n个数的和是p的倍数,且其中至少有一个数是质数,答案对201704082017040820170408取模(n≤1e9, ...

  5. C++ MFC棋牌类小游戏day6

    双人单机小游戏做完了,规则那部分还没介绍,暂时不打算介绍了,因为写的这个bug太多,我打算重新修改. 链接:https://pan.baidu.com/s/1XQKPSv0Tw36Qi2TeaRJiM ...

  6. Azkaban使用安装文档

    Azkaban使用安装文档 Azkaban简介 Azkaban的是什么 Azkaban是由Linkedin公司推出的一个批量工作流任务调度器,用于在一个工作流内以一个特定的顺序运行一组工作和流程.Az ...

  7. 学以致用二十七-----Centos7.5二进制安装mysql5.7.23

    首先去官网查看mysql版本.才一个礼拜不到,我之前下载的是mysql5.7.23,现在在官网页面已然找不到了,只有5.7.24版本,不得不说更新真快.不过我下载的是mysql5.7.23,所以还是安 ...

  8. web服务器原理(作业四)

      Web服务器简介:Web服务器是指驻留于因特网上某种类型计算机的程序.当web浏览器(客户端)连到服务器上并请求文件时,服务器将处理该请求并将文件发送到该浏览器上,附带的信息会告诉浏览器如何查看该 ...

  9. 20155326刘美岑 Exp6 信息收集与漏洞扫描

    20155326刘美岑 Exp6 信息收集与漏洞扫描 实验后回答的问题 (1)哪些组织负责DNS,IP的管理. 全球根服务器均由美国政府授权的ICANN统一管理,负责全球的域名根服务器.DNS和IP地 ...

  10. 你应该这么理解TCP的三次握手和四次挥手

    前言: TCP协议是计算机的基础,他本身是一个非常非常复杂的协议. 本文只是蜻蜓点水,将从网络基础以及TCP的相关概念介绍开始,之后再将三次握手,四次挥手这些内容来阐述. 最后介绍一些常见问题,并给出 ...