Problem 1604 - Play Apple
Time Limit: 1000MS   Memory Limit: 65536KB    Total Submit: 434  Accepted: 174  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. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<algorithm>
  6. using namespace std;
  7. const int INF = 0x3f3f3f3f;
  8. typedef long long LL;
  9. int main(){
  10. LL N;
  11. while(~scanf("%lld",&N)){
  12. if(N == || N == ){
  13. puts("No");
  14. }
  15. else if(N == ){
  16. puts("Yes");
  17. }
  18. else{
  19. if((N - ) % == ){
  20. puts("No");
  21. }
  22. else puts("Yes");
  23. }
  24. }
  25. return ;
  26. }

Play Apple(博弈)的更多相关文章

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

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

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

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

  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. Eight(South Central USA 1998)(八数码) 分类: bfs 2015-07-05 22:34 1人阅读 评论(0) 收藏

    The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've see ...

  2. poj 2411 新写法

    别以为我在刷水题.... 今天做了场srm,500pt想到了是dp但是无从下手,但是看了rng_58的神代码后顿觉海阔天空啊(盯着看了一个下午),相比于一年前的写法,真的是不忍直视啊, TC真是个好地 ...

  3. 计算机管理cmd命令行

    给你一个资料,想必对你来讲有保存价值: 开始菜单中的“运行”是通向程序的快捷途径,输入特定的命令后,即可快速的打开Windows的大部分程序,熟练的运用它,将给我们的操作带来诸多便捷. winver ...

  4. mysql命令具体解释

    首先创建一个简单的user表 CREATE TABLE `user` ( `id`  int NOT NULL AUTO_INCREMENT , `name`  varchar(255) NULL , ...

  5. Win8 使用VC6.0调试

    Win8.1下无法执行vc++6.0的解决方法 注意 安装过程中最后一步会卡在那里不动,能够直接关闭安装程序,忽略报错. 1 安装完毕后在安装文件夹下找到MSDEV.EXE 而且将 MSDEV.EXE ...

  6. toj2867 Picking Problem

    题目链接:http://acm.tju.edu.cn/toj/showp.php?pid=2867 题目大意:给定一系列活动的开始时间和结束时间,问最多能参加的活动数目 思路:// 本题属于最大区间调 ...

  7. 9年经验,总结SEO职业瓶颈

    昨天与某集团的副总与部门总监沟通了一些关于SEO发展与瓶颈的问题,有很多感触,今天整理出来分享给大家.其实关于SEO瓶颈这个话题已经不是一年两年了,很多新人老人越来越困惑,9年历程一路风雨走来,希望能 ...

  8. poj 3894 System Engineer (二分图最大匹配--匈牙利算法)

    System Engineer Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 507   Accepted: 217 Des ...

  9. SQL SERVER 2005 错误:18456

    安装好SQL SERVER 2005之后,Windows身份验证无法登陆,出现18456错误.而sql server 身份验证可以用sa用户登陆. 解决办法: 用sa用户登陆,执行SQL 语句: CR ...

  10. AliCTF 2016

    上上周参加了阿里的CTF,靠着最后绝杀队伍有幸拿到了国内第一名,也顺利进入了XCTF Final.把自己做的几个题简单写了下,发出来也算个总结吧. PWN-FB 经典的null byte overfl ...