POJ 1082 博弈推规律
来源:互联网 发布:数据分析法 编辑:程序博客网 时间:2024/05/08 09:40
Description
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.
Input
Output
Sample Input
3 2001 11 3 2001 11 2 2001 10 3
Sample Output
YESNONO
题意:从1月1号到11月4号的任意时间开始,谁先到11月4号谁胜利,下一步可以到下一天或者到下一个月的这天,当下个月没这天就只能走下一天。
来自discuss里的思想:
11月4号是月份+天数的和为奇,即和为奇是必败态,一般情况下每一步可以使月份+天数的和奇偶性改变,但是月末的一天例外。下面罗列了所有月末的一天到下月的第一天出现奇偶不变的情况:
2-28 =》3-1(偶=>偶)
4-30 =》5-1(偶=>偶)
6-30 =》7-1(偶=>偶)
9-30 =》10-1(奇=>奇)
11-30 =》12-1(奇=>奇)
显然对结果有改变的有:
1).某一必胜态“只能”转换到另一必胜态(偶=>偶)(对对方来说,到他了,虽然是偶数,但是他的下一步还是只能走到偶数给对方让对方赢,所以即使他是偶数他还是输)
2).某一必败态“可以”转换到另一必败态(奇=>奇)(对自己来说,虽然自己是奇数,但下一步可以走到奇数,让对方来输)(注意这两种情况的下一步都不是走到像这两种特殊情况来说)
而2-28还可以跳转到3-28
而4-30还可以跳转到5-30
而6-30还可以跳转到7-30
因此前面3个不满足1).而后面2个满足2)
所以9-30和11-30可以让对方为奇数为对自己来说就是必胜态,
另外只要不是对手一开始就是9-30和11-30这两个状态,那么己方一定能避免对手走到这两个状态:(即这两个特别的状态不会影响其他状态的胜败情况)
假如对方是状态9-30,则一定是由己方面临9-29/8-30得到,那么己方可以分别走10-29/8-31来避免对方面临9-30.
11-30同理。
#include <iostream>#include <cstdio>using namespace std;int main() { int T; cin>>T; while(T--) { int year,month,day; cin>>year>>month>>day; if(((day+month)%2==0)||((month==9||month==11)&&day==30)) { puts("YES"); } else puts("NO"); } return 0;}
- POJ 1082 博弈推规律
- poj 1082 Calendar Game 博弈递推
- 博弈 找规律 poj 2484
- POJ 3517 找规律、递推
- POJ 1082 Calendar Game 找规律博弈(存在特殊情况)
- POJ 2505 A multiplication game(找规律博弈)
- POJ 2348 Euclid's Game (博弈找规律 )
- 【POJ 2505】A multiplication game 博弈 - 找规律
- 【POJ 2484】A Funny Game 博弈找规律
- 博弈,找规律_______A Funny Game(poj 2484)
- poj 2505 A multiplication game (博弈+找规律)
- POJ 1740 A New Stone Game 博弈,规律
- POJ 2348 Euclid's Game( 总结规律+组合博弈 )
- POJ 2484 A Funny Game(规律直推)
- POJ 1082 (博弈)
- Poj 1082 (博弈)
- [POJ](1740)A New Stone Game --找规律博弈(博弈)
- HDOJ1525 [找规律博弈]
- VTK:测量类widget总结
- 使用Android Studio遇到的坑
- 算法训练 JAM计数法
- 【zzulioj 2134: 维克兹的进制转换】+ dp
- [Codeforces VK Cup 2016
- POJ 1082 博弈推规律
- 新品活动,1000件套装,限量免.费赠送CHANEL礼盒三件套(邂逅香水+coco香水+口红)Z
- STL库之Map结构的使用
- Java动态代理之CGLIB
- 【Ubuntu】手动建立快捷方式
- Windbg 实战常用命令--会不断更新
- CC2640 自学mark
- 大数据数据分析POM.XML
- velocity的一些用法