HDU1850 Being a Good Boy in Spring Festival(博弈)
| Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
Description
春节回家 你能做几天好孩子吗
寒假里尝试做做下面的事情吧
陪妈妈逛一次菜场
悄悄给爸爸买个小礼物
主动地 强烈地 要求洗一次碗
某一天早起 给爸妈用心地做回早餐
如果愿意 你还可以和爸妈说
咱们玩个小游戏吧 ACM课上学的呢~
下面是一个二人小游戏:桌子上有M堆扑克牌;每堆牌的数量分别为Ni(i=1…M);两人轮流进行;每走一步可以任意选择一堆并取走其中的任意张牌;桌子上的扑克全部取光,则游戏结束;最后一次取牌的人为胜者。
现在我们不想研究到底先手为胜还是为负,我只想问大家:
——“先手的人如果想赢,第一步有几种选择呢?”
Input
Output
Sample Input
5 7 9
0
Sample Output
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
int a[],ans=,cnt=;
for(int i=;i<n;i++)
{
cin>>a[i];
ans^=a[i];
}
for(int i=;i<n;i++)
{
if(a[i]>(ans^a[i]))//注意加括号
cnt++;
}
//以下这段话看不懂也没关系。 在本代码中 1.可以将cout 0那句去掉 2.可以在大于判断的时候加上等号
//但是两者不能同时用 因为有一个数的等于成立那么所有的数的等于都成立 即cnt=n 也就是异或为0先手必败的情况
//如果两者同时用会把先手必败的输出0的情况变为输出n 这样是错误的 但是单独用没问题
if(ans)
cout<<cnt<<endl;
else
cout<<<<endl;
}
return ;
}
HDU1850 Being a Good Boy in Spring Festival(博弈)的更多相关文章
- HDU1850 Being a Good Boy in Spring Festival
/* HDU1850 Being a Good Boy in Spring Festival http://acm.hdu.edu.cn/showproblem.php?pid=1850 博弈论 尼姆 ...
- Being a Good Boy in Spring Festival(博弈)
Being a Good Boy in Spring Festival Problem Description一年在外 父母时刻牵挂春节回家 你能做几天好孩子吗寒假里尝试做做下面的事情吧 陪妈妈逛一次 ...
- HDU1850 - Being a Good Boy in Spring Festival 【尼姆博弈】
一年在外 父母时刻牵挂 春节回家 你能做几天好孩子吗 寒假里尝试做做下面的事情吧 陪妈妈逛一次菜场 悄悄给爸爸买个小礼物 主动地 强烈地 要求洗一次碗 某一天早起 给爸妈用心地做回早餐 ...
- hdu 1850 Being a Good Boy in Spring Festival(Nimm Game)
题意:Nimm Game 思路:Nimm Game #include<iostream> #include<stdio.h> using namespace std; int ...
- Being a Good Boy in Spring Festival(尼姆博弈)
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...
- Being a Good Boy in Spring Festival(杭电1850)(尼姆博弈)
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
- HDU 1850 Being a Good Boy in Spring Festival (Nim博弈)
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
- HDU.1850 being a good boy in spring festival (博弈论 尼姆博弈)
HDU.1850 Being a Good Boy in Spring Festival (博弈论 尼姆博弈) 题意分析 简单的nim 博弈 博弈论快速入门 代码总览 #include <bit ...
- HDUOJ-------Being a Good Boy in Spring Festival
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
随机推荐
- Bzoj1150 数据备份Backup
Description 你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份.然而数据备份的工作是枯燥乏味 的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家 ...
- hihocoder 1154 Spring Outing
传送门 #1154 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring ...
- tomcat管理员配置
纸上得来终觉浅,绝知此事要躬行 博客园 首页 新闻 新随笔 联系 管理 随笔- 458 文章- 0 评论- 38 Tomcat的Manager显示403 Access Denied 管理to ...
- SSH协议及其应用
SSH协议及其应用 原文作者:阮一峰 链接: http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html http://www.ruany ...
- Get value from agent failed: cannot connect to [[192.168.186.130]:10050]: [113]No route to host
客户端配置zabbix-agent 后,网页端出现Get value from agent failed: cannot connect to [[192.168.186.130]:10050]: [ ...
- mysqli 操作数据库(转)
从php5.0开始增加mysql(i)支持 , 新加的功能都以对象的形式添加 i表示改进的意思 功能多.效率高.稳定 编译时参数: ./configure --with-mysql=/usr/bin/ ...
- Struts2中基于Annotation的细粒度权限控制
Struts2中基于Annotation的细粒度权限控制 2009-10-19 14:25:53| 分类: Struts2 | 标签: |字号大中小 订阅 权限控制是保护系统安全运行很重要 ...
- dedecms首页调用的简介一直修改不了是自动文章摘要在作怪
一位美女问:dedecms首页调用的简介一直修改不了,ytkah让她到具体的文章修改,然后再重新生成一下首页.她说还是不行.那就奇了怪了,点击到具体的文章页面是显示已经修改好了,为什么首页还是原来的呢 ...
- Open Credit System
Open Credit SystemInput: Standard Input Output: Standard Output In an open credit system, the studen ...
- IIS计数器
Bytes Total/sec 是 Bytes Sent/sec 与 Bytes Received/sec 的总和.这是 Web 服务每秒传输的总字节数. Cache Total Turnover R ...