传送门

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t;
  9. scanf("%d",&t);
  10. while(t--)
  11. {
  12. int n,a,res=0;
  13. int c=0,g=0;//¹Âµ¥¶Ñ¡¢³äÔ£¶Ñ
  14. scanf("%d",&n);
  15. for(int i=0;i<n;i++)
  16. {
  17. scanf("%d",&a);
  18. if(a>=2) c++;
  19. else if(a==1) g++;
  20. res^=a;
  21. }
  22. if(!res)//Òì»òΪ0£¬ÎªT̬
  23. {
  24. if(c>=2)//T2
  25. printf("Brother\n");
  26. else if(c==0)
  27. printf("John\n");
  28. }
  29. else//S
  30. {
  31. if(g&1&&c==0)//S0
  32. printf("Brother\n");
  33. else if(c==1||c>=2)//S1,S2
  34. printf("John\n");
  35. }
  36. }
  37. return 0;
  38. }

HDU 1907 John(取火柴博弈2)的更多相关文章

  1. HDU - 1907 John 反Nimm博弈

    思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1.  每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选 ...

  2. HDU 1907 John (Nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  3. hdu 1907 John (尼姆博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  4. POJ 3480 &amp; HDU 1907 John(尼姆博弈变形)

    题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...

  5. HDU 1907 John nim博弈变形

    John Problem Description   Little John is playing very funny game with his younger brother. There is ...

  6. HDU 1907 John(博弈)

    题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...

  7. hdu 1907 John&& hdu 2509 Be the Winner(基础nim博弈)

    Problem Description Little John is playing very funny game with his younger brother. There is one bi ...

  8. HDU 2509 Be the Winner(取火柴博弈2)

    传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...

  9. hdu 1907 (尼姆博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907 Problem Description Little John is playing very ...

随机推荐

  1. 安卓自动化测试工具一:Monkey

    一:monkey的用途:主要用于稳定性测试,模拟用户操作 二.monkey的基本使用 monkey文档地址:"<android_sdk>/docs/tools/help/monk ...

  2. MIT线性代数课程 总结与理解-第一部分

    概述 个人认为线性代数从三个角度,或者说三个工具来阐述了线性关系,分别是: 向量 矩阵 空间 这三个工具有各自的一套方法,而彼此之间又存在这密切的联系,通过这些抽象出来的工具可以用来干一些实际的活,最 ...

  3. C#中的重写和覆盖的区别

    #中重写(override)和覆盖(new)的区别 重写用关键字 virtual 修饰的方法,叫虚方法.可以在子类中用override 声明同名的方法,这叫“重写”.相应的没有用virtual修饰的方 ...

  4. 主成分分析(Principal components analysis)-最大方差解释

    原文:http://www.cnblogs.com/jerrylead/archive/2011/04/18/2020209.html 在这一篇之前的内容是<Factor Analysis> ...

  5. error: a label can only be part of a statement and a declaration is not a statement

    GCC: error: a label can only be part of a statement and a declaration is not a statement switch(a){ ...

  6. Web Scraper使用

    { "selectors": [{ "parentSelectors": ["_root"], "type": &quo ...

  7. Unity 解决 An asset is marked with HideFlags.DontSave but is included in the build 问题。

    问题是:不能使用Unity使用的默认的字体.想要显示中文直接去下载一个字体.没必要使用默认的字体

  8. nginx 搭建 文件下载服务

    location / { root /home/data-nginx/; index index.html index.htm; autoindex on; ##显示索引 autoindex_exac ...

  9. JQuery 模糊匹配

    [属性名称]         匹配包含给定属性的元素 [att=value]       匹配包含给定属性的元素      [att*=value]     模糊匹配      [att!=value ...

  10. java栈内存堆内存和GC相关

    java栈内存堆内存 Java把内存分成两种,一种叫做栈内存,一种叫做堆内存,有着不同的作用.栈内存用来存储局部变量和方法调用.栈内存归属于单个线程,每个线程都会有一个栈内存,其存储的变量只能在其所属 ...