Be the Winner

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3591    Accepted Submission(s): 2009

Problem Description
Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is 
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
 
Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
 
Output
If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
 
Sample Input
2
2 2
1
3
 
Sample Output
No
Yes
 
Source
 
 
 
 #include <bits/stdc++.h>
using namespace std; int main()
{
int n;
int a;
int i;
int sum, twos;
while (~scanf("%d", &n)) {
sum = , twos = ;
for (i = ; i < n; ++i) {
scanf("%d", &a);
sum ^= a;
if (a >= ) {
++twos;
}
}
if (sum > && twos == || sum == && twos >= ) {//s0, t2
printf("No\n");
} else {
printf("Yes\n");
}
}
return ;
}

hdu 2509 Be the Winner(anti nim)的更多相关文章

  1. 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 ...

  2. hdu 1907 John (anti—Nim)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)http://acm.h ...

  3. hdu 1907 John(anti nim)

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

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

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

  5. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  6. HDU 5783 Divide the Sequence(数列划分)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. HDU 3496 Watch The Movie(看电影)

    HDU 3496 Watch The Movie(看电影) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] New sem ...

  8. HDU 5224 Tom and paper(最小周长)

    HDU 5224 Tom and paper(最小周长) Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d &a ...

  9. HDU 5868 Different Circle Permutation(burnside 引理)

    HDU 5868 Different Circle Permutation(burnside 引理) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=586 ...

随机推荐

  1. python面试题(六)

    1 异常处理写法以及如何主动跑出异常(应用场景) try: """执行语句""" except: #异常类型 ""&qu ...

  2. 动态生成ABAP程序-资料

    参考程序: Tcode ABAPdocu--> BC - ABAP Programming--> The ABAP Programming Language--> Special T ...

  3. (转)fiddler使用简介--其二

    原文地址:http://www.cnblogs.com/miantest/p/7290176.html 在上一篇中介绍了Fiddler的基本使用方法.通过上一篇的操作我们可以直接抓取浏览器的数据包.但 ...

  4. NodeJS应用程序设置为window service-辅助工具(C#)

    1.修改nssm,去对话框后 2.生成批处理文件,执行 3.将nssm.exe.node.exe放在资源文件里面 附代码 工具

  5. Android 工具类 SharedPreferences 封装

    SharedPreferences 是 Android 数据存储方式中的一种,特别适合用来存储少量的.格式简单的数据,比如应用程序的各种配置信息,如是否打开音效,是否开启震动等等. SharedPre ...

  6. 前端 初级篇(HTML)

    HTML 概述: HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都来遵守他,这样就 ...

  7. iOS JS 和 OC交互 / JS 和 native 相互调用

    现在app 上越来越多需求是通过UIWebView 来展示html 或者 html5的内容, js 和 native OC代码交互 就非常常见了. js 调用 native  OC代码 第一种机制 ( ...

  8. Apache Kudu

    Apache Kudu是由Cloudera开源的存储引擎,可以同时提供低延迟的随机读写和高效的数据分析能力.Kudu支持水平扩展,使用Raft协议进行一致性保证,并且与Cloudera Impala和 ...

  9. Apache commons-io实现多文件读取和写入

    需求: "E:/data/"目录下有四个文件夹,如下: 每个文件夹下有几个.csv文件,如下: 将每个文件夹下的.csv文件合并成一个以该文件夹命名的.csv文件. 做法: 找到& ...

  10. python 课堂笔记-if语句

    # Author:zyl _username = 'zyl' _password = 'zyl123' username = input("username:") password ...