Be the Winner HDU - 2509(反博弈。。这样叫应该没错吧。。)
就是 好几堆苹果 每堆苹果排成一条线 可以任意从每堆拿苹果 如果一堆苹果里拿了之后 则有两种情况
1、从不是边缘拿 拿完这一堆变成两堆
2、从边缘拿 拿完还是一堆
题目还要求 谁拿最后一堆 谁输。。这种类型的分析看这个吧 https://www.cnblogs.com/WTSRUVF/p/9339499.html
看着其他人直接异或。。我还是练一下sg吧。。。。
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int sg[maxn];
int w;
void mex()
{
mem(sg, );
bool vis[maxn];
for(int i=; i<=w; i++)
{
mem(vis, );
for(int j=; j<=i; j++)
{
vis[sg[i-j]] = ;
int tot = i-j;
for(int k=; k<tot; k++)
vis[sg[k]^sg[tot-k]] = ;
}
for(int j=; ; j++)
if(!vis[j])
{
sg[i] = j;
break;
}
}
} int main()
{
int n;
while(cin>> n)
{
int cnt = , res = ;
for(int i=; i<n; i++)
{
cin>> w;
mex();
res ^= sg[w];
if(w == ) cnt++;
}
if(res && cnt != n)
cout<< "Yes" <<endl;
else if(!res && cnt == n)
cout<< "Yes" <<endl;
else
cout<< "No" <<endl; } return ;
}
Be the Winner HDU - 2509(反博弈。。这样叫应该没错吧。。)的更多相关文章
- HDU 2509 Nim博弈变形
1.HDU 2509 2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...
- HDU 2509 nim博弈
Be the Winner Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- HDU 2509 基础Anti-SG NIM
如果我们规定当局面中所有的单一游戏的SG值为0时,游戏结束,则先手必胜当且仅当:(1)游戏的SG!=0 && 存在单一游戏的SG>1:(2)游戏的SG==0 && ...
- HDU 4315 阶梯博弈变形
n个棋子,其中第k个是红色的,每个棋子只能往上爬,而且不能越过.重叠其他棋子,谁将红色棋子移到顶部谁赢. 由于只能往上爬,所以很像阶梯博弈.这题有2个限制,棋子不能重叠,有红棋存在 首先不考虑红色棋, ...
- HDU 1564 简单博弈 水
n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为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 ...
- HDU 2509 Be the Winner nim博弈变形
Be the Winner Problem Description Let's consider m apples divided into n groups. Each group contai ...
- hdu 2509 Be the Winner 博弈
题目链接 有n堆苹果, 对于其中的每一堆的x个苹果, 它是放在一条线上的. 你每次可以对一堆苹果进行操作, 可以取y个, 1<=y<=x. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...
- (step8.2.2)hdu 2509(Be the Winner——简单博弈)
题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数....其实理解为什么都没关系, 重要的是,理解就行....).在接下来的一行中,有 ...
随机推荐
- python里的魔法方法1(构造与析构)
魔法方法——构造与析构 1.python编程的魔法方法: (1)魔法方法总是被双下划线包围,例如__init__: (2)魔法方法是面向对象的python的一切. 2.__new__(class[,… ...
- 百度地图在移动端下click无效的解决方案
这是由于百度地图在移动端屏蔽了click事件,在网上找到一种方法,利用touchClick方法来模拟click事件,代码如下(需要JQ插件): //给jquery添加touchClick方法 (fun ...
- Java字符串连接操作的性能问题
首先,看一段实验程序: package com.test; class StringTest { public static void main(String[] args) { long start ...
- vue mock(模拟后台数据) 最简单实例(一)——适合小白
开发是前后端分离,不需要等待后台开发.前端自己模拟数据,经本人测试成功. 我们在根目录新建存放数据的json文件,存放我们的数据data.json //data.json{ "status& ...
- 学习python,第一篇
name = "danie" name2 = name print(name,name2) name = "itxpl" print(name,name2) 结 ...
- ROS (Robot Operating System) 相关资料与文档
本博文持续更新…… ROS学习与实践保护很多资料,最权威的当然是官网: www.ros.org 当然也有很多其他博文,尤其是中文文档有助于理解.2017推出一篇新博文,概况的资料较全. http:// ...
- umask命令详解
基础命令学习目录首页 原文链接:https://blog.csdn.net/stpeace/article/details/45509425 umask命令用得相对不多, 而umask函 ...
- CentOs6.5中安装和配置vsftp简明教程[转]
CentOs6.5中安装和配置vsftp简明教程 林涛 发表于:2017-3-17 10:10 分类:WebServer 标签: 101次 一.vsftp安装篇 复制代码代码如下: # 安装vsftp ...
- 20181023-11 Alpha发布
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2283 文案: Learning by Playing 界面清爽明快,UI ...
- kafka启动报错:另一个程序正在使用此文件,进程无法访问。
在Windows上启动kafka_2.12-1.1.0报以下错误:[2018-05-08 10:24:51,777] ERROR Failed to clean up log for __consum ...