HDU 3970 Paint Chain (博弈,SG函数)
Paint Chain
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 909 Accepted Submission(s): 325
Now, they thought this game is too simple, and they want to change some rules. In each turn one player must select a certain number of consecutive unpainted beads to paint. The other rules is The same as the original. Who will win under the rules ?You may assume that both of them are so clever.
3 1
4 2
Case #2: abcdxyzk
用SG函数搞一遍就可以了。
/* ***********************************************
Author :kuangbin
Created Time :2013-11-17 19:20:19
File Name :E:\2013ACM\比赛练习\2013-11-17\H.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
const int MAXN = ;
int sg[MAXN];
bool vis[MAXN];
int m;
int mex(int n)
{
if(sg[n] != -)return sg[n];
if(n < m)return sg[n] = ;
memset(vis,false,sizeof(vis));
for(int i = m;i <= n;i++)
vis[mex(i-m)^mex(n-i)] = true;
for(int i = ;;i++)
if(vis[i] == false)
{
sg[n] = i;
break;
}
return sg[n];
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
int n;
scanf("%d",&T);
int iCase = ;
while(T--)
{
scanf("%d%d",&n,&m);
iCase++;
if(n < m)
{
printf("Case #%d: abcdxyzk\n",iCase);
continue;
}
n -= m;
memset(sg,-,sizeof(sg));
for(int i = ;i <= n;i++)
sg[i] = mex(i);
if(sg[n] == )printf("Case #%d: aekdycoin\n",iCase);
else printf("Case #%d: abcdxyzk\n",iCase);
}
return ;
}
HDU 3970 Paint Chain (博弈,SG函数)的更多相关文章
- HDU 3980 Paint Chain (sg函数)
Paint Chain Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU - 3980 Paint Chain(SG函数)
https://vjudge.net/problem/HDU-3980 题意 一串长度为n的柱子,每个人只能给连续的珠子涂色,涂过的不能再涂,不能涂的人就输了,问最后谁获胜. 分析 第一个人先涂m个, ...
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- hdu 3980 Paint Chain 组合游戏 SG函数
题目链接 题意 有一个\(n\)个珠子的环,两人轮流给环上的珠子涂色.规定每次涂色必须涂连续的\(m\)颗珠子,无法继续操作的人输.问先手能否赢. 思路 参考 转化 第一个人取完之后就变成了一条链,现 ...
- hdu 3032(博弈sg函数)
题意:与原来基本的尼姆博弈不同的是,可以将一堆石子分成两堆石子也算一步操作,其它的都是一样的. 分析:由于石子的堆数和每一堆石子的数量都很大,所以肯定不能用搜索去求sg函数,现在我们只能通过找规律的办 ...
- HDU 1848 Fibonacci again and again (斐波那契博弈SG函数)
Fibonacci again and again Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & ...
- hdu 5795 A Simple Nim 博弈sg函数
A Simple Nim Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
- HDU-4678 Mine 博弈SG函数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4678 题意就不说了,太长了... 这个应该算简单博弈吧.先求联通分量,把空白区域边上的数字个数全部求出 ...
- hdu-3980-nim博弈/sg函数
Paint Chain Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
随机推荐
- PHP扩展开发--编写一个helloWorld扩展
为什么要用C扩展 C是静态编译的,执行效率比PHP代码高很多.同样的运算代码,使用C来开发,性能会比PHP要提升数百倍. 另外C扩展是在进程启动时加载的,PHP代码只能操作Request生命周期的数据 ...
- 第11月第3天 直播 rtmp yuv
1. LiveVideoCoreSDK AudioUnitRender ==> MicSource::inputCallback ==> GenericAudioMixer::pushBu ...
- 如何使用gifsicle压缩gif图片
最近我写了一些关于如何将各种形式的多媒体格式相互转换的文章,特别是GIF动图方面的,比如如何将小视频转换成GIF动图或将GIF动图转换成视频,有很多像ImageMagick,ffmpeg这样的工具帮助 ...
- shell中后台进程管理: ps -aux 详解
常用 查找进程id方法: ps -aux | grep "jupyter" 杀进程: kill -9 具体的PID 1.ps命令 要对进 ...
- java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@59f1ca76 rejec ...
- Java中包的介绍
包的介绍: 未命名包 命名包 可以避免类名重复 为了更好地组织类,Java 提供了包机制,用于区别类名的命名空间. 包的作用 1.把功能相似或相关的类或接口组织在同一个包中,方便类的查找和使用. 2. ...
- window批处理——bat文件的编写
BAT 批处理脚本 教程 第一章 批处理基础第一节 常用批处理内部命令简介 批处理定义:顾名思义,批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT或者CMD.这些命 ...
- 在centos中修改yum源为阿里源
cd /etc/yum.repos.d 备份旧的配置文件:mv CentOS-Base.repo CentOS-Base.repo.bak 下载阿里源的文件: wget -O CentOS-Base. ...
- android短信验证
短信验证demo http://download.csdn.net/detail/crazy1235/8315279#comment 使用MOB平台开发,用法详见: http://blog.csdn. ...
- fis3-postpackager-loader
静态资源前端加载器,用来分析页面中使用的和依赖的资源(js或css), 并将这些资源做一定的优化后插入页面中.如把零散的文件合并. 注意 此插件做前端硬加载,适用于纯前端项目,不适用有后端 loade ...