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. PHP删除目录

    function delDir($directory) { if(file_exists($directory)) { $dir_handle = @opendir($directory); if($ ...

  2. Java读写配置文件prop.properties

    Java读写配置文件prop.properties @Test public void fun() throws IOException{ Properties prop=new Properties ...

  3. Thread Group(线程组)

    线程组,可以理解用户池,用来产生线程(用户),每一个线程代表一个用户,在使用JMeter进行性能测试过程中,经常需要模拟多个用户进行测试,可以通过设置线程数代表多少个用户,通常一个线程组就代表一个测试 ...

  4. MySQL 学习笔记(二):数据库更新、视图和数据控制

    基础准备: 在 school 数据库下建立student.course.sc 三个表: create table student( Sno ) primary key, Sname ) unique, ...

  5. 题解 P1534 【不高兴的津津(升级版)】

    题目链接 不算太难.就是题目有歧义. wa了好几次才发现.上一天要是小于8的话.结算是昨天一个负值在加上今天课时数.再减去8.233.... 而不是上一天小于8个小时.就清零了..大家要注意(ps:题 ...

  6. linux下Tomcat+OpenSSL配置单向&双向认证(自制证书)

    背景 由于ios将在2017年1月1日起强制实施ATS安全策略,所有通讯必须使用https传输,本文只针对自制证书,但目前尚不确定自制证书是否能通过appstore审核. 1.必须支持传输层安全(TL ...

  7. MongDB集群部署

    http://blog.csdn.net/luonanqin/article/details/8497860 参数解释: dbpath:数据存放目录 logpath:日志存放路径 pidfilepat ...

  8. JDBC_PreparedStatement用法_占位符_参数处理

    import java.sql.Connection; import java.sql.Date;import java.sql.DriverManager;import java.sql.Prepa ...

  9. 分布式中为什么要加入redis缓存的理解

    面我们介绍了mybatis自带的二级缓存,但是这个缓存是单服务器工作,无法实现分布式缓存.那么什么是分布式缓存呢?假设现在有两个服务器1和2,用户访问的时候访问了1服务器,查询后的缓存就会放在1服务器 ...

  10. vue从一个页面跳转到另一个页面并携带参数

    1.需求: 点击商场跳转到商业体列表 解决方案: 元页面: a标签中添加跳转函数 <a class="orderBtn1 sIRicon2" href="javas ...