標籤:
Problem 1604 - Play AppleTime Limit: 1000MS Memory Limit: 65536KB
Total Submit: 442 Accepted: 177 Special Judge: NoDescription
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?
InputThere are multiple test cases.
The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )OutputIf the first person will win, output “Yes”. Otherwise, output “No”.Sample Input2
3
4Sample OutputNo
Yes
No 題目大意:兩個人分蘋果。兩種操作:(1)第一個人把蘋果分成不相等的兩堆 (2)第二個人挑一堆留下,下輪繼續玩。 當某個人不能操作的時候,他就輸了。 問你如果兩個人都採用最優策略,第一個人是否會贏。
#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;typedef long long LL;int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n == 1 || n == 2){ puts("No"); }else if(n == 3){ puts("Yes"); }else{ if((n-3) % 3 == 1){ puts("No"); }else{ puts("Yes"); } } } return 0;}
Whu 1604——Play Apple——————【博弈】