WHU 1604--play Apple —————— "Game"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.