Problem 1604 - Play Apple
Time Limit: 1000MS   Memory Limit: 65536KB   
Total Submit: 442  Accepted: 177  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 )
Output
If the first person will win, output “Yes”. Otherwise, output “No”.
Sample Input
2
3
4
Sample Output
No
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——————【博弈】的更多相关文章

  1. Play Apple(博弈)

    Problem 1604 - Play Apple Time Limit: 1000MS   Memory Limit: 65536KB    Total Submit: 434  Accepted: ...

  2. codeforces 812E Sagheer and Apple Tree(思维、nim博弈)

    codeforces 812E Sagheer and Apple Tree 题意 一棵带点权有根树,保证所有叶子节点到根的距离同奇偶. 每次可以选择一个点,把它的点权删除x,它的某个儿子的点权增加x ...

  3. codeforces 812 E. Sagheer and Apple Tree(树+尼姆博弈)

    题目链接:http://codeforces.com/contest/812/problem/E 题意:有一颗苹果树,这个苹果树所有叶子节点的深度要不全是奇数,要不全是偶数,并且包括根在内的所有节点上 ...

  4. Codeforces 812E Sagheer and Apple Tree ——(阶梯博弈)

    之前在bc上做过一道类似的阶梯博弈的题目,那题是移动到根,这题是移动到叶子.换汤不换药,只要和终态不同奇偶的那些位置做nim即可.因此这题给出了一个条件:所有叶子深度的奇偶性相同.同时需要注意的是,上 ...

  5. Codeforces Round #417 (Div. 2)A B C E 模拟 枚举 二分 阶梯博弈

    A. Sagheer and Crossroads time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. CodeForces 812E Sagheer and Apple Tree 树上nim

    Sagheer and Apple Tree 题解: 先分析一下, 如果只看叶子层的话. 那么就相当于 经典的石子问题 nim 博弈了. 那我们看非叶子层. 看叶子层的父亲层. 我们可以发现, 如果从 ...

  7. dp --- acdream原创群赛(16) --- B - Apple

    <传送门> B - Apple Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Other ...

  8. iOS: 在iPhone和Apple Watch之间共享数据: App Groups

    我们可以在iPhone和Apple Watch间通过app groups来共享数据.方法如下: 首先要在dev center添加一个新的 app group: 接下来创建一个新的single view ...

  9. hdu----(1849)Rabbit and Grass(简单的尼姆博弈)

    Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. Quicksort------代码之美

    #include<iostream> #include<cstdlib> #include<time.h> using namespace std; void sw ...

  2. D:大整数的加减乘除

    描述 给出两个正整数以及四则运算操作符(+ - * /),求运算结果. 输入第一行:正整数a,长度不超过100第二行:四则运算符o,o是“+”,“-”,“*”,“/”中的某一个第三行:正整数b,长度不 ...

  3. spring boot日志及Log4j日志配置

    1.默认实现的日志配置 Spring boot默认已经集成了logging,同时也是默认开启的,如果想根据自己的需求对日志进行配置,方法很简单--只需要在配置文件中进行相应设置,这里提供我自己的配置如 ...

  4. 【ARC074F】Lotus Leaves 最小割

    Description 给你一个n*m网格图,有起点荷叶和终点荷叶,有中转荷叶,其他的格子没东西,一个荷叶可以跳到同一行或者列的另一个荷叶.问最多删掉几个中转荷叶能让起点终点不连通.如果不行输出-1. ...

  5. Unity---动画系统学习(2)---模型3种导入方式、人形动画介绍、切割动画

    1. 介绍 Unity中导入的模型主要是由3DMAX.Maya等建模软件制作的,后缀为.fbx的文件. 博主在Unity Asset Store里面下载了一套官方免费的模型和动画. 和一套地图,分享给 ...

  6. winform跨线程问题(有参数和无参数)

    1.invoke是同步线程 using System; using System.Collections.Generic; using System.ComponentModel; using Sys ...

  7. 5.js与jQuery入口函数执行时机

    js与jQuery入口函数执行时机区别: JS入口函数是在所有资源加载完成后,才执行.(包括:页面.外部js文件.外部css文件.图片) jQuery入口函数,是在文档加载完成后就执行.文档加载完成指 ...

  8. python pika简单实现RabbitMQ通信

    Windows上安装及启动RabbitMQ https://blog.csdn.net/hzw19920329/article/details/53156015 安装python pika库 pip ...

  9. CentOS 中查看软件的版本号

    CentOS  中查看软件的版本号 1. rpm 查看 [root@hadoop110 ~]# rpm -qa | grep mysql mysql-community-client--.el6.x8 ...

  10. 【转】idea中maven模块编程灰色

    可能是设置中模块的pom.xml文件被忽略了 去掉对勾 转自:https://blog.csdn.net/ethan__xu/article/details/80794060