博弈论(男人八题):POJ 1740 A New Stone Game
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 5694 | Accepted: 3119 |
Description
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
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
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的更多相关文章
- poj 1741 楼教主男人八题之中的一个:树分治
http://poj.org/problem? id=1741 Description Give a tree with n vertices,each edge has a length(posit ...
- poj 1737男人八题之一 orz ltc
这是楼教主的男人八题之一.很高兴我能做八分之一的男人了. 题目大意:求有n个顶点的连通图有多少个. 解法: 1. 用总数减去不联通的图(网上说可以,我觉得时间悬) 2. 用动态规划(数学递推) ...
- POJ1742 Coins(男人八题之一)
前言 大名鼎鼎的男人八题,终于见识了... 题面 http://poj.org/problem?id=1742 分析 § 1 多重背包 这很显然是一个完全背包问题,考虑转移方程: DP[i][j]表示 ...
- Cogs 1714. [POJ1741][男人八题]树上的点对(点分治)
[POJ1741][男人八题]树上的点对 ★★★ 输入文件:poj1741_tree.in 输出文件:poj1741_tree.out 简单对比 时间限制:1 s 内存限制:256 MB [题目描述] ...
- POJ 1740 A New Stone Game(博弈)题解
题意:有n个石子堆,每一个都可以轮流做如下操作:选一个石堆,移除至少1个石子,然后可以把这堆石子随便拿几次,随便放到任意的其他石子数不为0的石子堆,也可以不拿.不能操作败. 思路:我们先来证明,如果某 ...
- poj 1742(好题,楼天城男人八题,混合背包)
Coins Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 33269 Accepted: 11295 Descripti ...
- poj 1743 男人八题之后缀数组求最长不可重叠最长重复子串
Musical Theme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14874 Accepted: 5118 De ...
- 新男人八题---AStringGame
终于完成进度男人1/8,为了这题学了sam= = 题意先有一个串,n个子串,两个人轮流每次在子串上加字符,要求加完后还是原串的子串,最后不能加的就是输者,求赢的人 解法:sam之后在构造的状态图上跑s ...
- POJ 1740 A New Stone Game 又是博弈论配对找规律orz 博弈论 规律
http://poj.org/problem?id=1740 这个博弈一眼看上去很厉害很高大上让人情不自禁觉得自己不会写,结果又是找规律…… 博弈一般后手胜都比较麻烦,但是主要就是找和先手的对应关系, ...
随机推荐
- 利用Inltellj创建javadoc ,用jd2chm创建chm
现在有些框架都不带javadoc 就需要自己去生成,而且真正用起来还是chm的最方便,所以写篇日志记录一下 下面我就拿struts2的源码来来举个栗子 1.第一步:创建一个空的java项目,导入框架源 ...
- 分享:Svg文件转换为图片(调用 Inkscape 命令行)
其实只是做了简单封装,可以方便进行批量转换. 获取Svg对象坐标的代码请看:根据svg节点对象类型和路径值转换坐标值, DrawingColor方法是进行颜色填充的. /// <summary& ...
- LINQ 多条件写法
源代码: string depAll = (ddl_dep1.SelectedValue == "") ? "" : ddl_dep1.SelectedValu ...
- Java-jfree报表(学习整理)----饼状图、柱状图、折线统计图
1.使用的报表工具: jfree报表 2.下载网址: http://www.jfree.org/ 下载之后先解压:如下图 下载后:需要的jar包!如下图: 打开:找到以下的两个jar包 再导入开发项目 ...
- Win32中GDI+应用(五)--GDI与GDI+编程模型的区别
在GDI里面,你要想开始自己的绘图工作,必须先获取一个device context handle,然后把这个handle作为绘图复方法的一个参数,才能完成任务.同时,device context ha ...
- [Neural Networks] Momentum
一.目的 加快参数的收敛速度. 二.做法 另第t次的权重更新对第t+1次的权重更新造成影响. 从上式可看出,加入momentum后能够保持权重的更新方向,同时加快收敛.通常alpha的取值为[0.7, ...
- IS脚本学习
OnFirstUIBefore:函数块用于第一安装应用时安装部件前所要完成的任务.一般在这里进行下列设: 1. 设置屏蔽 2. 显示欢迎信息,软件协议书或关于软件安装的其他说明信息 3. 从用户处获取 ...
- CURL传输与获取功能
什么是CURL? 利用URL语法爱命令行方式下工作的文件传输工具.它支持很多协议.它支持认证功能.php中常用都实现更复杂的传输功能. 实现的功能: 1.实现远程获取和采集内容 2.实现PHP 网页版 ...
- java 抓取百度根据关键词搜索域名
package baidusearch; import com.sun.glass.ui.SystemClipboard; import java.util.*; import java.util.H ...
- iOS: 神奇的addSubView
看着addSubView, 本以为是添加多个对象, 但通过测试代码, 发现同一个对象在addSubView中只会添加一次. 想想, 视图对象是通过引用得到的. 在视图的子视图集中, 只保存一个相应的对 ...