A New Stone Game
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 5694   Accepted: 3119

Description

Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob move the stones in turn.
At each step of the game,the player choose a pile,remove at least
one stones,then freely move stones from this pile to any other pile that
still has stones.

For example:n=4 and the piles have (3,1,4,2) stones.If the player
chose the first pile and remove one.Then it can reach the follow states.

2 1 4 2

1 2 4 2(move one stone to Pile 2)

1 1 5 2(move one stone to Pile 3)

1 1 4 3(move one stone to Pile 4)

0 2 5 2(move one stone to Pile 2 and another one to Pile 3)

0 2 4 3(move one stone to Pile 2 and another one to Pile 4)

0 1 5 3(move one stone to Pile 3 and another one to Pile 4)

0 3 4 2(move two stones to Pile 2)

0 1 6 2(move two stones to Pile 3)

0 1 4 4(move two stones to Pile 4)

Alice always moves first. Suppose that both Alice and Bob do their best in the game.

You are to write a program to determine who will finally win the game.

Input

The
input contains several test cases. The first line of each test case
contains an integer number n, denoting the number of piles. The
following n integers describe the number of stones in each pile at the
beginning of the game, you may assume the number of stones in each pile
will not exceed 100.

The last test case is followed by one zero.

Output

For each test case, if Alice win the game,output 1,otherwise output 0.

Sample Input

3
2 1 3
2
1 1
0

Sample Output

1
0
http://blog.csdn.net/zhang20072844/article/details/8113381这个题解很清楚。
 #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int a[],f,n;
int main(){
while(scanf("%d",&n)!=EOF&&n){
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
if(n%==)printf("1\n");
else{
f=;sort(a+,a+n+);
for(int i=;i<n;i+=)
if(a[i]!=a[i+])f=;
printf("%d\n",f);
}
}
return ;
}
												

博弈论(男人八题):POJ 1740 A New Stone Game的更多相关文章

  1. poj 1741 楼教主男人八题之中的一个:树分治

    http://poj.org/problem? id=1741 Description Give a tree with n vertices,each edge has a length(posit ...

  2. poj 1737男人八题之一 orz ltc

    这是楼教主的男人八题之一.很高兴我能做八分之一的男人了. 题目大意:求有n个顶点的连通图有多少个. 解法: 1.  用总数减去不联通的图(网上说可以,我觉得时间悬) 2.    用动态规划(数学递推) ...

  3. POJ1742 Coins(男人八题之一)

    前言 大名鼎鼎的男人八题,终于见识了... 题面 http://poj.org/problem?id=1742 分析 § 1 多重背包 这很显然是一个完全背包问题,考虑转移方程: DP[i][j]表示 ...

  4. Cogs 1714. [POJ1741][男人八题]树上的点对(点分治)

    [POJ1741][男人八题]树上的点对 ★★★ 输入文件:poj1741_tree.in 输出文件:poj1741_tree.out 简单对比 时间限制:1 s 内存限制:256 MB [题目描述] ...

  5. POJ 1740 A New Stone Game(博弈)题解

    题意:有n个石子堆,每一个都可以轮流做如下操作:选一个石堆,移除至少1个石子,然后可以把这堆石子随便拿几次,随便放到任意的其他石子数不为0的石子堆,也可以不拿.不能操作败. 思路:我们先来证明,如果某 ...

  6. poj 1742(好题,楼天城男人八题,混合背包)

    Coins Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 33269   Accepted: 11295 Descripti ...

  7. poj 1743 男人八题之后缀数组求最长不可重叠最长重复子串

    Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14874   Accepted: 5118 De ...

  8. 新男人八题---AStringGame

    终于完成进度男人1/8,为了这题学了sam= = 题意先有一个串,n个子串,两个人轮流每次在子串上加字符,要求加完后还是原串的子串,最后不能加的就是输者,求赢的人 解法:sam之后在构造的状态图上跑s ...

  9. POJ 1740 A New Stone Game 又是博弈论配对找规律orz 博弈论 规律

    http://poj.org/problem?id=1740 这个博弈一眼看上去很厉害很高大上让人情不自禁觉得自己不会写,结果又是找规律…… 博弈一般后手胜都比较麻烦,但是主要就是找和先手的对应关系, ...

随机推荐

  1. Activity以singleTask模式启动,intent传值的解决办法

    转载请注明出处,谢谢http://blog.csdn.net/harryweasley/article/details/46557827 因为项目中,有一个消息推送的功能,每次推送一个消息,就会开启F ...

  2. javascript - 图片的幻灯片效果

    javascript 代码: <script type="text/javascript"> function select_play() { var select_p ...

  3. centos 彻底卸载mysql

    yum remove mysql mysql-server mysql-libs compat-mysql51rm -rf /var/lib/mysqlrm /etc/my.cnf查看是否还有mysq ...

  4. hdu Train Problem I(栈的简单应用)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  5. [学习笔记]设计模式之Facade

    写在前面 为方便读者,本文已添加至索引: 设计模式 学习笔记索引 Facade(外观)模式定义了一个高层接口,它能为子系统中的一组接口提供一个一致的界面,从而使得这一子系统更加容易使用.欢迎回到时の魔 ...

  6. Windows phone 之 UserControl的应用

    一.新建一个UserControl.xaml页面  MyUserControl.xaml 添加代码如下: <UserControl x:Class="bodypicture.MyUse ...

  7. 【elasticsearch】(4)centos7 超简单安装elasticsearch 的 jdbc

    前言 elasticsearch(下面简称ES)使用jdbc连接mysql比go-mysql-elasticsearch的elasticsearch-river-jdbc能够很好的支持增量数据更新的问 ...

  8. WinFrom ProgressBar控件的使用

    在WinForm程序中,大多数情况下我们是知道程序运行所需要的时间或步骤的,比如批量复制文件时文件的数量,数据导出或导入时数据的总行数等等.对于步骤比较确定的操作,如果程序执行过程时间较长,很容易使用 ...

  9. Cloudera Impala 之 ORDER BY without LIMIT currently not supported

    ERROR: NotImplementedException: ORDER BY without LIMIT currently not supported   impala中order by 需要l ...

  10. js 默认的参数、可变的参数、变量作用域

    可以通过arguments对象来实现可变的参数 在函数代码中,使用特殊对象 arguments,开发者无需明确指出参数名,就能访问它们. arguments是一个数组对象,可以通过下标来实别参数的位置 ...