landoj--1604--Play Apple(博弈)
来源:互联网 发布:苹果海马助手软件 编辑:程序博客网 时间:2024/05/18 00:56
1604 - Play Apple
Time Limit: 1000MS Memory Limit: 65536KB
Total Submit: 441 Accepted: 176 Special Judge: No
Total Submit: 441 Accepted: 176 Special Judge: No
Description
There are N apples. Two people take turns to either:
1. Divide the apple into two piles with different numbers.
2. The other people selects a pile of apples as the beginning of the next turn.
If someone can not meet the requirements, he is lost. Will the first one win the game if both use the best strategy?
Input
There are multiple test cases.
The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )
The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )
Output
If the first person will win, output “Yes”. Otherwise, output “No”.
Sample Input
2
3
4
3
4
Sample Output
No
Yes
No
Yes
No
题意:现在有一堆苹果,这些苹果有n个,第一个人将苹果分为两份,这两份的数目应该是不一样的,第二个人选一堆分为不同的两份,循环下去,直到有一个人分不下去
思路:从小到大列举每一个数,看他们是必败点还是必胜点,然后就可以找到规律了,1,2为必败点,3是必胜点,大于3之后如果这个数减1之后还可以被3整除,那麽这个数就是必败点,否则就是必胜点
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){int n;while(scanf("%d",&n)!=EOF){if(n==3)printf("Yes\n");else if(n==1||n==2)printf("No\n");else if((n-1)%3==0)printf("No\n");else printf("Yes\n");}return 0;}
0 0
- landoj--1604--Play Apple(博弈)
- WHU 1604 - Play Apple【博弈】
- Land oj 1604 - Play Apple (博弈)
- Whu oj 1604 - Play Apple
- Play a game + 博弈
- hdu 4597 Play Game (博弈dp)
- HDU--1564 -- play a game [博弈]
- HDU 1564 Play a game 规律博弈
- HDU 1564 Play a game(博弈)
- HDU 1564 Play a game 博弈
- HDU 1564--Play a game【博弈】
- HDU 1564 Play a game 简单博弈
- hdu4597 (博弈dp)play game
- hdu1564 Play a game【博弈 找规律】
- 博弈——Play a game
- ACdream群OJ 1131 Apple 博弈
- 杭电hdu 1564 Play a game 博弈?
- HDU 1564 Play a game(规律博弈)
- 链接网页
- java函数加载顺序
- 将一个正整数分解质因数
- 判断三个数是否是直角三角形的三条边
- Qt一步一步实现插件调用(附源码)
- landoj--1604--Play Apple(博弈)
- cmd常用命令及操作
- 2016.4.10 第一次测试选择题
- Qt一步一步实现插件通信(附源码)
- JavaScript 计时事件
- csv导入oracle数据库
- Qt 一步一步实现dll调用(附源码)
- 天猫开店流程及费用,怎么计算天猫店铺的开店成本?
- LeetCode *** 19. Remove Nth Node From End of List