Problem 1604-play Apple
Time Limit: 1000MS
Memory Limit: 65536KB
Total Submit: 442
Accepted: 177
Special Judge: nodescription
There is N apples. People take turns to either:
1. Divide the apple into and 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. Would the first one win the game if both use the best strategy?
Inputthere is multiple test cases.
The first line of all case contains a integer n. (1 <= N <= 1000000000) outputif The first person would win, output "Yes". Otherwise, Output "No". Sample Input2
3
4Sample Outputno
Yes
No topic: Two people divide apples. Two operations: (1) The first person divides the apples into two unequal piles (2) The second person picks a bunch of leaves and continues to play. When someone is unable to operate, he loses. Ask you if two people are using the best strategy, whether the first person will win.
#include <stdio.h> #include <algorithm> #include <string.h>using namespace std;typedef 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 —————— "Game"