E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
S-Nim
HDU1536/POJ2960
S-Nim
题目大意有一个集合SSS,其元素个数为kkk。两个人玩mmm轮游戏,每轮游戏有nnn堆石子,每次游戏两个人轮流在这nnn堆石子中选一堆,从这一堆中取走若干个石子,取走石子的个数必须为SSS集合中的一个元素的值。双方都采用最优策略,问先手是否必胜。必胜则输出WWW,否则输出LLL。有多组数据。数据范围1≤k≤100,1≤si≤100001\leqk\leq100,1\leqs_i\leq100001
tanjunming2020
·
2023-04-09 14:28
题解
c++
题解
hdu 1536
S-Nim
|| poj 2960
S-Nim
(sg函数)
#include#includeints[110];intsg[10010],hash[110];intn,m;intgetsg(intx)//sg模板{inti;if(sg[x]!=-1)returnsg[x];memset(hash,0,sizeof(hash));for(i=0;i=s[i]){sg[x-s[i]]=getsg(x-s[i]);//s[i]为可以抓的数hash[sg[x-s[
lihaogegehuting
·
2020-08-24 22:19
HDU
poj
博弈
sg函数
Ninm
HDU 1536 -
S-Nim
(SG)
S-NimTimeLimit:5000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):4585AcceptedSubmission(s):1989ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimfors
coco430
·
2020-08-24 13:21
HDU
博弈
[ACM] hdu 1536
S-Nim
(Nim组合博弈 SG函数打表)
S-NimTimeLimit:5000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):4004AcceptedSubmission(s):1732ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimfors
weixin_33982670
·
2020-08-13 21:16
POJ 2960
S-Nim
题意:在普通的Nim游戏上加入一些限制。给定一个集合S,每次只能取S的元素个石子。题解:SG函数。#includeusingnamespacestd;#defineMAXN105#defineMAXM10005inth[MAXN];ints[MAXN];intSG[MAXM];intk;voidDFS(intx){if(SG[x]!=-1)return;boolcheck[MAXM]={0};in
ConwayTian
·
2020-08-13 12:51
博弈论
ACM-SG函数之
S-Nim
——hdu1536 hdu1944 poj2960
S-NimTimeLimit:5000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):4091AcceptedSubmission(s):1760ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimfors
ltree98
·
2020-08-13 10:04
ACM-博弈
漫漫刷题路
hdu 1944
S-Nim
(博弈论-求SG函数)
ArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionhasanumberofheaps,allcontainingsome,notnecessarilyequal,numberofbeads.Theplayerstaketurnscho
T__TSZ
·
2020-08-03 14:11
S-Nim
(fromHDU)(博弈问题)(Sprague-Grundy定理)
题目描述:ArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionhasanumberofheaps,allcontainingsome,notnecessarilyequal,numberofbeads.Theplayerstaketur
coldfresh
·
2017-04-07 23:31
算法分析
博弈论
nim
【模版】hdu1536
S-Nim
看刘汝佳《算法竞赛入门经典训练指南》2.4只看了点皮毛……hdu1536#include #include #include #defineN10005 #defineM105 usingnamespacestd; intsg[N],can[M]; intn,m,k; boolvis[N]; intdfs_sg(intx){ if(vis[x])returnsg[x]; vis[x]=1; boo
yxr0105
·
2016-05-12 11:00
HDU
组合游戏
poj2960——
S-Nim
(SG函数)
DescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionhasanumberofheaps,allcontainingsome,notnecessarilyequal,numberofbeads.Theplayerst
blue_skyrim
·
2016-05-11 21:00
游戏
c
函数
ACM
poj
poj 2960
S-Nim
Nim博弈变形 有限取法
A- S-NimTimeLimit:1000MS MemoryLimit:32768KB 64bitIOFormat:%I64d&%I64uSubmit StatusDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows: Thesta
wr132
·
2016-04-25 15:00
poj
2960
S-Nim
有限取法
Nim博弈变形
HDOJ-1536
S-Nim
当我们面对由n个游戏组合成的一个游戏时,只需对于每个游戏找出求它的每个局面的SG值的方法,就可以把这些SG值全部看成Nim的石子堆,再用异或进行求解#include #include #include #include #include #include #definemaxn10006 usingnamespacestd; intdp[10005],num[105],d[105]; void
qq_26122039
·
2016-04-04 11:00
poj 2960
S-Nim
S-NimTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 3735 Accepted: 1959DescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionha
clover_hxy
·
2016-04-02 20:00
【POJ2960】
S-Nim
(博弈SG函数)
题目描述传送门题解简单的SG函数。根据规则建立SG函数。其中sg[0]=0。代码#include #include #include #include usingnamespacestd; constintmax_n=105; constintmax_sg=10005; intn,m,k,x,ans; intrule[max_n],sg[max_sg],ext[max_sg]; inline
Clove_unique
·
2016-03-13 18:00
poj 2960
S-Nim
S-NimTimeLimit:2000MSMemoryLimit:65536KTotalSubmissions:3735Accepted:1959DescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionhasanumb
clover_hxy
·
2016-03-11 23:41
博弈问题
hdu1536
S-Nim
TimeLimit:5000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5856 AcceptedSubmission(s):2507ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimf
Kirito_Acmer
·
2016-01-24 11:00
博弈
HDU 1536
S-Nim
师时隔几个月后,在看博弈NIM终于懂了,做出了第一道根据所有堆的异或和的题 题意:在一个Si容器中,输入可以行走的步数,然后在下面T组测试数据中,输入堆的情况 View Code #include<stdio.h> #include<algorithm> using namespace std; //数组超是开小了 还是开大了 int enable[1
·
2015-11-13 15:27
HDU
hdu 1809 A New Tetris Game(2)
pid=1809 这个题是 “A New Tetris Game” 的升级版 第一 需要用SG处理 第二 需要记录状态 由于有多个棋盘 所以要对应到
S-Nim
里面的值 而且数据变多了
·
2015-11-13 14:46
game
hdu 1536
S-Nim
pid=1536
S-Nim
博弈 需要用SG 处理 最简单的
S-Nim
博弈是 每一堆可以任取正整数个 比如说 k 可以变成 k-1,k-2,k-3,···
·
2015-11-13 13:33
HDU
【HDU】1536
S-Nim
http://acm.hdu.edu.cn/showproblem.php?pid=1536 题意:同nim...多堆多询问...单堆n<=10000,每次取的是给定集合的数= = #include <cstdio> #include <cstring> using namespace std; bool b[105]; int s[105], f[10
·
2015-11-13 11:07
HDU
hdu 1536 SG函数模板题
S-Nim
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java
·
2015-11-13 08:54
HDU
对近期poj hdu 博弈问题的一些总结
POJ 2960
S-Nim
大意:有n堆石子,每堆石子个数已知,两人轮流从中取石子,每次可取的石子数x满足x属于集合S(k) = {s1,s2,s3...sk-1},问先拿者是否有必胜策略?
·
2015-11-13 06:34
poj
解题报告 HDU1944
S-Nim
S-Nim
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java
·
2015-11-13 04:38
HDU
hdu 1536(博弈)
传送门:
S-Nim
题意:给n个数的集合s, 再给m 组数据,每组表示 k 堆石子,每次可以取的个数只能是集合s中的数量。问先手胜还是输?
·
2015-11-13 04:40
HDU
POJ 2960
S-Nim
【SG函数的应用】
id=2960POJ 2960
S-Nim
大意:有n堆石子,每堆石子个数已知,两人轮流从中取石子,每次可取的石子数x满足x属于集合S(k) = {s1,s2,s3...sk-1},问先拿者是否有必胜策略
·
2015-11-12 11:41
poj
HDU 1536
S-Nim
(博弈论)
SG函数模版,学习ing... 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 int dp[10001],n; 7 int p[1
·
2015-11-11 15:00
HDU
S-Nim
http://acm.hdu.edu.cn/showproblem.php?pid=1536 SG经典题,不多说 // File Name: hdu1536.cpp // Author: bo_jwolf // Created Time: 2013年09月30日 星期一 18:23:53 #include<vector> #include<lis
·
2015-11-10 22:10
IM
poj 2960
S-Nim
取石子游戏的变体。 题意:有m堆石子,事先给定一个集合S,每次只能从一堆中取石子,且取的石子个数必须是S中的数。没有石子可取或者不能按规则取石子即为输。 给定初始情况,判断最开始的局面是必败L,还是必胜W局面。 这题如果知道SG函数,就很好解了。由sg的基础知识可知,某一局面的sg值为0则对应P局面,反之对应N局面,所以把最终局面的sg值求出来就可以了。 这里在用到一个定理: 设gi
·
2015-11-09 12:29
poj
HDU 1536 与 1944
S-Nim
这是一道典型的SG函数题; View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<algorithm> 5 #include<cmath> 6 #include<queue> 7 #
·
2015-11-08 10:19
HDU
hdu 1536/1944 / POJ 2960 / ZOJ 3084
S-Nim
博弈论
简单的SG函数应用!!! 代码如下: 1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 #include<iomanip> 5 #include<cmath> 6 #include<cstring>
·
2015-11-07 14:31
poj
POJ 2960
S-Nim
<博弈>
链接:http://poj.org/problem?id=2960 1 #include<stdio.h> 2 #include<string.h> 3 const int N = 10001; 4 const int M= 101; 5 int SG[N];//SG[i]记录一堆i颗石子的SG状态 6 int s[M];//存储可选取的石子
·
2015-11-05 09:18
poj
SG 函数
S-Nim
id=2960
S-Nim
Time Limit: 2000MS Memory Limit: 65536K Total Submissions:&
·
2015-11-01 13:44
函数
HDU 1016
S-Nim
----SG求值
S-Nim
Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
·
2015-10-31 19:25
HDU
HDU 356
S-Nim
S-Nim
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission
·
2015-10-31 19:07
HDU
hdu 1536
S-Nim
(sg)
http://acm.hdu.edu.cn/showproblem.php?pid=1536 计算sg值。 注意两个地方: 1. s是无序的。 2. 不能对n=10000打表,因为能取的个数是给定的,会有打不到的点。 code: #include<cstdio> #include<cstring> int s[ 101], sg
·
2015-10-31 15:02
HDU
HDU 1536
S-Nim
HDU_1536 比较直观的思路将每一堆的sg函数计算出来,然后看所有的sg函数异或之后是否为0。但实际上我们没必要每一堆都独立计算一遍sg函数,因为游戏规则是一样的,所以sg函数也必然是一样,所以只用开一个一维的sg[]数组记录sg函数的值即可。 此外,一开始调用一下类似dp(10000)的递归函数企图预处理出sg[
·
2015-10-31 14:32
HDU
hdu 1536&&1944
S-Nim
sg函数 难度:0
S-Nim
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java
·
2015-10-30 13:25
HDU
ACM-SG函数之
S-Nim
——hdu1536 hdu1944 poj2960
S-Nim
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java
·
2015-10-27 16:50
ACM
hdu 1536
S-Nim
题意:首先输入K 表示一个集合的大小 之后输入集合 表示对于这对石子只能去除这个集合中的元素的 个数 之后输入一个m表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有 n个堆 每堆有n1个石子 问这一行所表示的状态是赢还是输 如果赢输入W否则L 思路: 对
·
2015-10-27 15:55
HDU
HDU_1536
S-Nim
(sg函数)
类似 Fibonacci again and again 貌似有点模板的感觉,就是不知到hash数组的上界是怎么算出来的,无语,继续研究去。。。 #include <iostream>#include <cstdio>using namespace std;const int N = 10010;const int M = 110;int num[M];int
·
2015-10-21 11:05
HDU
POJ-2960(
S-Nim
)——博弈论,SG函数
题意:两个人玩游戏,规则是有n堆石子,分别有a1,a2,...,an颗石头,每次从一堆石子中取一些石子,但是可取的石子数是规定了的,必须是{s1,s2,...,sk}中的一个,谁无法操作就输。 思路:一开始我还是不懂的,不知道怎么选择SG函数值。但是回去研读了一下SG函数的定义,就明白了:相对于朴素的NIM游戏,可取的石子数是有限制的,那就按照SG函数的定义进行递归求解SG值,然后将每一堆的SG
shengtao96
·
2015-09-23 14:00
博弈论
sg函数
HDU 1536
S-Nim
(博弈论)
Description有多堆石子,每次只能从一堆石子取走集合S中某一元素数值的石子,两人轮流取,谁不能取谁输,假设两人足够机智,问先手输赢Input多组大用例,每组大用例第一行首先输入集合S的元素数k,之后输入k个整数表示S中的元素,第二行输入小用例组数m,之后m行每行首先输入石子堆数n,之后n个数表示每堆石子的数量,以k=0结束输入Output每组大用例输出占一行,对于每组小用例,如果先手赢则输
V5ZSQ
·
2015-09-04 08:00
S-Nim
(hdu1536+SG函数)
S-NimTimeLimit:5000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5317 AcceptedSubmission(s):2288ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalle
u010579068
·
2015-08-04 21:00
数论
博弈
sg
S-Nim
hdu1536
HDOJ
S-Nim
1536&POJ
S-Nim
2960【求SG函数+Nim游戏】
S-NimTimeLimit:5000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5288 AcceptedSubmission(s):2275ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalle
ydd97
·
2015-07-28 17:00
hdu 1536 OR poj 2960
S-Nim
博弈论,,求出SG'函数就可以解决
S-NimTimeLimit:5000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):4975 AcceptedSubmission(s):2141ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalle
Lionel_D
·
2015-02-26 20:00
博弈论
sg函数
公平组合博弈
hdu1536
S-Nim
HDU 1536 & POJ 2960
S-Nim
(博弈 SG)
题目链接:HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1536POJ: http://poj.org/problem?id=2960ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows: T
u012860063
·
2015-02-04 21:00
HDU
博弈
sg
【POJ2960】
S-Nim
SG函数 博弈 裸题模板题
转载请注明出处:http://blog.csdn.net/vmurder/article/details/42653601其实我就是觉得原创的访问量比未授权盗版多有点不爽233。。。题意:两人轮流从若干堆石子中某堆取k个石子,k∈集合S,就是每次取的数量被限定成某几个数的意思!然后跟正常Nim一样谁不能操作就输。题解:SG函数裸题。SG函数:首先需要是有向无环图(拓扑图)首先确定边界状态,SG值为
Vmurder
·
2015-01-12 22:00
模板题
sg函数
S-Nim
裸题
POJ2960
HDU 1536
S-Nim
求SG函数
题意:给你n个数Nnum[i],表示每次只能取Nnum[i]个数。m个问题:每次给你l堆石子,每堆有num个石子,问先手是否会赢。SampleInput 225 3 2512 3247 423712 512345 3 2512 3247 423712 0 SampleOutput LWW WWL 经典Nim游戏,找出SG就可以了。至于如何找SG,这里有详细的 点我#
u012861385
·
2014-05-04 21:00
ACM-SG函数之
S-Nim
——hdu1536 hdu1944 poj2960
S-NimTimeLimit:5000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):4091 AcceptedSubmission(s):1760ProblemDescriptionArthurandhissisterCarollhavebeenplayingagamecalle
lx417147512
·
2014-05-03 09:00
ACM
博弈
and
sg函数
hdu1536
S-Nim
hdu1944
poj-2960
S-Nim
(博弈SG)
S-NimTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 3058 Accepted: 1622DescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionha
u012628310
·
2014-04-24 15:00
博弈
sg函数
上一页
1
2
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他