Whu 1604——Play Apple——————【博弈】

來源:互聯網
上載者:User

標籤:

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——————【博弈】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.