HDU 3032 Nim or not Nim?(博弈 sg表)

博弈类题目小结(HDU,POJ,ZOJ) 转载请注明出处,谢谢http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents    by---cxlove 首先当然要献上一些非常好的学习资料: 基础博弈的小结:http://blog.youkuaiyun.com/acm_cxlove/article/details/7854530 经典翻硬币游戏小结:http://blog.youkuaiyun.com/ac 阅读详情

Nim or not Nim?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1326    Accepted Submission(s): 656


Problem Description
Nim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap.

Nim is usually played as a misere game, in which the player to take the last object loses. Nim can also be played as a normal play game, which means that the person who makes the last move (i.e., who takes the last object) wins. This is called normal play because most games follow this convention, even though Nim usually does not.

Alice and Bob is tired of playing Nim under the standard rule, so they make a difference by also allowing the player to separate one of the heaps into two smaller ones. That is, each turn the player may either remove any number of objects from a heap or separate a heap into two smaller ones, and the one who takes the last object wins.
 

Input
Input contains multiple test cases. The first line is an integer 1 ≤ T ≤ 100, the number of test cases. Each case begins with an integer N, indicating the number of the heaps, the next line contains N integers s[0], s[1], ...., s[N-1], representing heaps with s[0], s[1], ..., s[N-1] objects respectively.(1 ≤ N ≤ 10^6, 1 ≤ S[i] ≤ 2^31 - 1)
 

Output
For each test case, output a line which contains either "Alice" or "Bob", which is the winner of this game. Alice will play first. You may asume they never make mistakes.
 

Sample Input
  
2 3 2 2 3 2 3 3
 

Sample Output
  
Alice Bob
 

Source
 

Recommend
gaojie   |   We have carefully selected several similar problems for you:   3031  3033  3035  3034  3036 
 







#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define bug printf("hihi\n")

#define eps 1e-8
typedef __int64 ll;

using namespace std;

#define INF 0x3f3f3f3f
#define N 10005

int main()
{
     int i,j,t;
     int n;
     scanf("%d",&t);
     while(t--)
     {
         scanf("%d",&n);
         int ans=0;
         int x;
         while(n--)
         {
             scanf("%d",&x);
             if(x%4==1)
                ans^=x;
             if(x%4==2)
                ans^=x;
             if(x%4==0)
                ans^=(x-1);
             if(x%4==3)
                ans^=(x+1);
         }
         if(ans)
            printf("Alice\n");
         else
            printf("Bob\n");
     }
     return 0;
}



/*
 打sg 表看规律

 sg(4k)=4k-1;sg(4k+1)=4k+1;sg(4k+2)=4k+2;sg(4k+3)=4k+4;


#include<iostream>
#include<string.h>
#include<cstdio>
#define N 1000001
using namespace std;
int sg[N];
int g(int x)
{
    int mex[1000];
    memset(mex,0,sizeof(mex));
    if(sg[x]!=-1)  return sg[x];
    for(int i=x-1;i>=0;i--)
    {
        mex[g(i)]=1;
    }
    for(int i=1;i<=x/2;i++)
    {
        int ans=0;
        ans^=g(i);
        ans^=g(x-i);
        mex[ans]=1;
    }
    for(int i=0;;i++)
    if(!mex[i])  return sg[x]=i;
}
int main()
{
    int t , n ,x ;
    memset(sg,-1,sizeof(sg));
    sg[0]=0;
      n=100;
     for(int i=1;i<n;i++)
         g(i);
       for(int i=0;i<=20;i++)
       {
          printf("i=%d %d\n",i,sg[i]);
       }
    return 0;
}

/*


i=0 0
i=1 1
i=2 2
i=3 4
i=4 3
i=5 5
i=6 6
i=7 8
i=8 7
i=9 9
i=10 10
i=11 12
i=12 11
i=13 13
i=14 14
i=15 16
i=16 15
i=17 17
i=18 18
i=19 20
i=20 19

Process returned 0 (0x0)   execution time : 0.194 s
Press any key to continue.

*/



桑基图实战指南:Excel/Python/R三工具高效绘制方法 桑基图是一种以线条宽度编码流量大小、以节点位置表达流程阶段、以连接关系呈现数据流向的专项可视化技术,其核心原理在于‘宽即量、位即序、连即逻辑’。它并非装饰性图表,而是面向业务诊断的分析前置工具,尤其适用于预算分配、能源损耗、用户转化等存在明确单向流动与显著数值差异的场景。相比传统柱状图或漏斗图,桑基图能天然暴露系统瓶颈与隐性损耗,大幅提升决策效率。本文聚焦工程落地,覆盖Excel插件快速交付、Python Plotly交互开发、R networkD3生态集成三大主流路径,兼顾数据准备铁律、索引映射规范与中文 阅读详情

相关推荐

LabVIEW小白福音:手把手教你用NI采集卡搭建振动信号采集系统(附源码和避坑指南)

本文为LabVIEW初学者提供详细的NI采集卡振动信号采集系统搭建指南,涵盖硬件连接、驱动安装、信号处理及性能优化等关键步骤。特别针对振动信号采集系统中的常见问题提供解决方案,并附源码和避坑指南,帮助用户快速上手并避免常见错误。

weixin_30485379的博客 103

(HDU - 3032)Nim or not Nim?(尼姆博弈变形)

题目链接:Nim or not Nim? - HDU 3032 - Virtual Judge (ppsucxtt.cn) 题目大意:给你n堆石子,两个人轮流进行操作,每次可以从任意一堆中取走任意数量的石子,也可以将一堆石子分成两堆,最后无法操作者输。 这一看就是一个尼姆博弈的变形题目,尝试过后发现这道题目无法利用尼姆博弈本身的一些结论,我们只能利用sg函数进行求解,在求解sg函数时与尼姆博弈中求解sg函数过程差不多,就是多了一个分解操作,对于有n个石子的一堆石子,如果是一般的尼姆博弈的话,他的后继状态

AC__dream的博客 319

c#.net使用正则表达式验证文本中是否包含手机号码或电话号码?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Collections; namespace RegularPhoneApp { class Program

码农 3584

HDU-3032--Nim or not Nim?(博弈+SG打表)

题目分析: 这是一个经典的Multi-SG游戏的问题。 相较于普通的Nim游戏,该游戏仅仅是多了拆成两堆这样的一个状态。即多了一个SG(x+y)的过程。 而根据SG定理,SG(x+y)这个游戏的结果可以拆成SG(x)和 SG(y)游戏的结果的xor。 因此,在我们求SG函数的过程中,我们只需要再枚举一下拆成两堆的状态,即可获得Multi-SG游戏每个状态的SG函数。 但是题目中的数据范围较大(达...

橘嘉禾 100

Seafile搭建以及onlyoffice在线办公

部署seafile docker-compose.yml 如下: 参考此篇文章 version: '2.0' services: db: image: mariadb:10.1 container_name: seafile-mysql environment: - MYSQL_ROOT_PASSWORD=db_dev # mysql root的密码,同时修改 seafile的DB_ROOT_PASSWD与这个一致 - MYSQL_LOG_CONSOLE

dwdcth的专栏 4656

PSOC Creator 入门教程超详细

最近工作原因需要使用到赛普拉斯的一款芯片,奈何以前没有用过,所以趁这次也学习了一些简单的用法,总结一下,希望能帮到有需要朋友,因为网上关于这方面的文章少的可怜,详细点的更是少之又少!废话少说,正文开始.

qm_mq的博客 5744

HDU 3032(Multi-SG函数)

传送门 Nim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number...

Chen.Jr的博客 523

Nature、science、cell旗下刊物

Nature\science\cell子刊说明

计算机视觉 5605

hdu3032(sg博弈)

对于hdu3032题描述如下: Paste_Image.png Sample Input 2 3 2 2 3 2 3 3 Sample Output Alice Bob 如果不可以分成两堆,就是一个Nim的经典游戏。对于Nim游戏,有以下结论: a1 xor a2 xor ...xor an != 0 必胜态 a1 xor a2 xor ...xor ...

菜丫姐姐的专栏 212

Apollo Planning2.0决策规划算法代码详细解析 (1):环境搭建

1、官方提供连接:git clone https://github.com/ApolloAuto/application-pnc.git。此外,也更新了dreamview对pnc的支持,使得调试更加方便。apollo开源团队近期更新了planning版本,对代码进行了一定程度上的重构。(2)进入docker,并编译整个工程:./apollo.sh build_dbg。下载项目环境后使用aem进行环境配置;2、有一定基础建议直接拉取最新代码,自己手动进行编译。(1)环境安装: ./dev_start.sh。

自动驾驶Player的博客 1840

语音识别:PyAudio、SoundDevice、Vosk、openai-whisper、Argos-Translate、FunASR(Python)

本文介绍了Python中常用的音频处理库PyAudio,详细解析了其核心功能、核心概念和典型工作流程。PyAudio是一个跨平台的音频I/O库,支持音频录制、播放、实时流处理和低延迟操作。核心概念包括PyAudio类(管理音频设备和流)和Stream类(代表音频流)。文章重点讲解了open()方法的关键参数、回调函数的使用方式以及典型的工作流程,包括设备查询、流配置和资源释放。PyAudio适用于需要实时音频处理的场景,如语音识别和音频效果处理。

算法工程师 705

HDU 3032

HDU 3032 题意:有n堆,2个人,每次可以从某1堆中取出任意个(至少1个),或者把一堆分成2个小堆。 题目分析:   一开始看到把1堆分成很多堆,我还有点小激动啊!可是刚准备写就发现,每一堆的可能石子数居然那么大(2^31-1)!坑爹啊!记忆化搜索肯定不行...

banejiao9159的博客 212

VTK API 详解(134):vtkOBJWriter - 写入 OBJ 模型

是 VTK 中用于将数据写入 Wavefront OBJ 文件格式的类。OBJ 格式是广泛支持的 3D 网格模型格式,支持顶点、面和基本几何信息的保存,便于模型在多种三维软件间交换。

yumeiguo的博客 140

HDU 3032 Nim or not Nim?(sg函数博弈)

题目地址:HDU 3032 这题是很好用来练习sg函数打表的一题。 下面是sg函数值打表代码: #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define LL long l

scf0920 1332

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

HDU-3032Nim or not Nim?(SG打表)

题目传送门 Nim or not Nim? 题目大意 Alice和Bob做游戏,共有n堆石子,没堆石子为s[i]s[i]s[i]个,每一次可以从任意一堆中拿走任意个石子,也可以将一堆石子分为两个小堆。先拿完者获胜。 Alice先手 思路 用SG打表后 发现规律是 x=x−1 when (x%4==0)x=x-1\ when\ (x\%4==0)x=x−1 when (x%4==0) x=x+1 when (x%4==3)x=x+1\ when\ (

Kuricip的博客 206

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

hdu 3032 Nim or not Nim? 博弈

题目大意: Alice和Bob轮流取N堆石子,每堆S[i]个,Alice先,每一次可以从任意一堆中拿走任意个石子,也可以将一堆石子分为两个小堆。先拿完者获胜。(1 ≤ N ≤ 10^6, 1 ≤ S[i] ≤ 2^31 - 1) 可以看到S[i]的值可能非常大,如果计算每一堆的sg值是不现实的,所以需要我们找规律来计算给定的石堆的sg值。 找了半天规律,但是WA了,说明规

u013087645的专栏 598

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SG函数找规律练习-HDU3032- Nim or not Nim?

问题描述: 两人博弈,N堆石子,可以选择移走某一堆的任意数量的石子,也可以选择将这一堆分成任意两堆东西 解法: 1、SG函数求解 void init() { memset(sg,0,sizeof(sg)); // int m; sg[0] = 0; sg[1] = 1; for(int i = 1 ; i < maxn;i++) {

wxyfennie的博客 1088

HDU3032 Nim or not Nim? 博弈

Nim or not Nim? 单击666传送 Problem DescriptionNim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at leas

BobHuang的博客 279

【hdu 3032】Nim or not Nim?

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2016 Accepted Submission(s): 1048 Problem Description Nim is a two-player m...

AWCXV 117

HDU 3032 Nim or not Nim?(SG函数打表找规律)

Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2802    Accepted Submission(s): 1450   Problem Description Nim is a two-play...

shyoldman的博客 312

Nim or not Nim? (HDU-3032)(尼姆博弈+SG函数)

Nim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of o...

菜鸡的博客 553

HDU 3032 Nim or not Nim? (sg函数)

Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 623Accepted Submission(s): 288 Problem Description Nim is a two-play...

anvt77205的博客 137

sg函数训练——开窍篇

个人觉得,能做一道经典的题并理解透彻,往往比做对难度系数很大的题目更有意义。最近又训练了博弈,记录一些题目,来个小总结。hdu 3032 Nim or not Nim?http://acm.hdu.edu.cn/showproblem.php?pid=3032 大意:和普通的nim游戏相比,这里新添加了一种操作,可以把数字分成更小的两份。 分析: sg[0]=0 当i=1,取走1后剩下0,m

theArcticOcean 1002

Nim or not Nim? - hdu3032

题意: 两人博弈,N堆石子,可以选择移走某一堆的任意数量的石子,也可以选择将这一堆分成任意两堆东西。 思路:和nim游戏差不多,只是多了一个分成两堆的操作,分成两堆也就是计算两个子堆的异或,然后sg函数打表找规律,sg[0]=0,sg[1]=1,2可以变成1+1,1,0,sg[2]=2..... #include<bits/stdc++.h> using namespace s...

Endeavor_G的博客 196

Nim or not Nim? HDU - 3032(SG函数 找规律)

打表代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define maxn 156 int s[maxn],sg[maxn]; void init() { memset(sg,0,sizeof...

呼吸 218

HDU 3032 Nim or not Nim? Lasker's Nim

题目大意: 就是现在初始有多堆石子, 每次可以将任意一堆拿走任意个或者将这一对分成两堆(不为空), 拿走最后一颗石子的人胜利 问谁会获得胜利 大致思路: 这个是Lasker's Nim 的模型, 我是打表找出SG函数的规律做的... SG[4*k + 1] = 4*k + 1; SG[2*k + 2] = 4*k + 2; SG[4*k + 3] = 4*k + 4; SG

Gatevin的专栏 802
上一篇: HDU 1536 S-Nim(sg函数)
下一篇: HDU 3389 Game(博弈)
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值