HDU - 1536 S-Nim

ELPI:可嵌入λProlog解释器,解决逻辑引擎嵌入难题 解释器嵌入是现代程序分析工具中常见的技术需求。无论是Python还是Prolog,将解释器作为库嵌入宿主程序都面临运行时初始化、对象模型映射、异常边界等工程挑战。ELPI(Embeddable Lambda Prolog Interpreter)作为可嵌入的λProlog解释器,以高阶逻辑和HOAS为核心,通过pi、sigma、=>等机制优雅处理绑定变量与上下文,在逻辑层面直接表达类型规则。其技术价值在于提供高表达力的声明式规则引擎,适用于类型检查器、程序验证、编译器等领域。从“解释器为何难嵌入”这一通用问 阅读详情

题目:给你一个大小为k的集合, 对于这堆石子只能取这个集合中的元素的个数。其他的同nim游戏的规则。

问当前情况是先手必胜还是先手必败

思路:对于n堆石子可以分成n个单独的游戏来看

代码:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
//template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
//template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
//template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
// 0x3f3f3f3f3f3f3f3f
//0x3f3f3f3f

const int maxn=1e4+50;
int k,arr[maxn];
int sg[maxn];
int dfs(int n){
    if(sg[n]!=-1)
        return sg[n];
    bool mex[105];
    mm(mex,false);
    for(int i=1;i<=k;i++){
        if(n>=arr[i]){
            int x=dfs(n-arr[i]);
            mex[x]=true;
        }
        else
            break;
    }
    for(int i=0;;i++)
        if(!mex[i]){
            sg[n]=i;
            break;
        }
    return sg[n];
}
char str[105];
int main(){

    int n,m,x;
    while(~scanf("%d",&k)){
        if(k==0)
            break;
        for(int i=1;i<=k;i++)
            scanf("%d",&arr[i]);
        sort(arr+1,arr+k+1);
        mm(sg,-1);
        scanf("%d",&m);
        int len=0;
        while(m--){
            scanf("%d",&n);
            int SG=0;
            for(int i=1;i<=n;i++){
                scanf("%d",&x);
                SG^=dfs(x);
            }
            if(SG>0) str[len++]='W';
            else str[len++]='L';
        }
        str[len++]='\0';
        printf("%s\n",str);
    }
    return 0;
}


GCJ02坐标系转WGS84坐标系(已实地测试基本无偏差) 坐标系转化,GCJ02坐标系,WGS84坐标系 阅读详情

相关推荐

Linux安装Oracle sqlplus客户端工具

Linux安装Oracle sqlplus客户端工具

CSDN_Nan_Jiang_Li的博客 2785

hdu-1536 S-Nim SG函数

http://acm.hdu.edu.cn/showproblem.php?pid=1536 给出能够取的方法序列,然后求基本石子堆问题。 只要用S序列去做转移即可。 注意has初始化的一些技巧 #include <iostream> #include <vector> #include <set> #include <cstd...

dong52130的博客 190

基于Android平台下的健康管理APP/基于android的健康管理系统

随着网络科技的发展,移动智能终端逐渐走进人们的视线,相关应用越来越广泛,并在人们的日常生活中扮演着越来越重要的角色。因此,关键应用程序的开发成为影响移动智能终端普及的重要因素,设计并开发实用、方便的应用程序具有重要的意义和良好的市场前景。Android技术作为当前最流行的操作平台,自然也存在着大量的应用服务需求。 本课题研究的是基于Android技术平台的健康管理APP,开发这款健康管理APP主要是为了帮助用户可以不用约束时间与地点进行所需信息。本文详细讲述了健康管理APP的界面设计及使用,主要包括界面的

m0_73706453的博客 1441

HDU 1536 S-Nim 博弈,SG函数

HDU 1536 S-Nim博弈,SG函数 传送门:HDU 题意取石子游戏。 先给你一个数组长度k,然后是长度为k的数组。表示合法的取石子个数Si。 然后是n,表示n个询问。 每个询问有一个m,m堆石子,每堆mi个。每次操作允许在某一堆石子中取出Si个石子。问你当前状态谁最后赢。思路算是SG函数入门题吧。 两篇对我理解有帮助的博客:1。2。代码#include <cstdio> #inc

P.H.S 367

Keil5与ARM编译器V5安装指南:从下载到配置全流程解析

本文提供Keil5与ARM Compiler V5的完整安装与配置指南。针对新版Keil5默认不包含V5编译器导致老工程编译失败的问题,详细解析了从软件下载、授权管理到获取并正确安装ARM Compiler V5(AC5)的全流程,确保开发者能顺利搭建兼容老项目的稳定开发环境。

weixin_29158047的博客 902

Hdu 1536 S-Nim

S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others Problem Description Arthur and his sister Caroll have been playing a game called Nim for some time now

Magic__ 884

【雕爷学编程】MicroPython手册之 Teensy 4.1 实时时钟 (RTC)

在类的初始化函数中,定义了用于控制I2C总线的i2c对象和RTC模块的I2C地址。接着,使用该引脚初始化了一个Pin对象。它还提供了8个串口,3个SPI端口,3个I2C端口,2个I2S/TDM数字音频端口,3个CAN总线(其中一个支持CAN FD),以及一个SDIO(4位数据)原生SD卡端口12。2、内存:Teensy 4.1配备了1024 KB的RAM(其中512 KB是紧密耦合的),8 MB的Flash(其中64 KB用于恢复和EEPROM模拟),以及两个位置可以选择添加更多的QSPI内存芯片。

雕爷学编程 578

【hdu 1536】S-Nim

Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7410 Accepted Submission(s): 3127 Problem Description Arthur and his sister...

AWCXV 159

2026华为OD机试真题 11月4日 新系统 【汽车出行路线重复检测】

华为OD机试真题 新系统【汽车出行路线重复检测】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【汽车出行路线重复检测】多语言题解。

qq_45776114的博客 455

YOLOv8【第十二章:数据增强与数据工程篇·第10节】主动学习(Active Learning):如何挑选最有价值的样本进行标注!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏。该专栏系统复现并梳理全网各类 YOLOv8 改进与实战案例(当前已覆盖分类 / 检测 / 分割 / 追踪 / 关键点 / OBB 检测等方向),坚持持续更新 + 深度解析,质量分长期稳定在 97 分以上,可视为当前市面上 覆盖较全、更新较快、实战导向极强 的 YOLO 改进系列内容之一。

**My Coding Family** 515

HDU 1536 S-Nim(尼姆博弈)

题目链接:HDU 1536 S-Nim 尼姆博弈。 题目说的很乱,其实比较简单,打个sg表就行了。 错了几次。哎。模版都没用明白。具体看这里吧。 #include #include #include #include //#define test using namespace std; const int MAX_N = 10000 + 20; //f[]:可以取走的石子个数

fobdddf的专栏 827

uniapp - [全端兼容] 高性能 tabbar 底部菜单凸起效果,原生系统自定义底部菜单不卡顿、切换页面不闪烁、自动缓存页面(底部菜单中间自定义一个图片并悬浮起来)

uniapp如何实现底部凸起按钮,uniapptabbar底部菜单怎么自定义,uniapp怎么让底部菜单中间突出来,uniapp自定义底部tabbar,uniapp高性能好用的底部菜单,uniapp自定义底部导航栏并解决闪烁问题,uniapp怎么设置凸起的底部tabbar,uniapp怎么用系统的底部菜单还想让中间的按钮凸起来,uniapp自定义tabbar性能不好怎么办,uni-app自定义导航栏实现中间凸起效果,uniapp底部导航栏中间圆形按钮凸起效果详细代码,uni-app自定义中间图标突起的

🏆 前端领域优质创作者 1万+

【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]...

129

深度学习工具包 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")

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

HDU1536 S-Nim

题目链接:https://vjudge.net/problem/HDU-1536 题目大意:   给一个数集\(S\),稍微修改\(Nim\)游戏的规则:原本是能在一堆里面取任意个数的石子,现在变成只能取\(n(n \in S)\)个石子,当没得取石子时判负。对于给定的局面,问先手的胜负条件。 知识点:  博弈论 解题思路:   首先引用贾志豪的论文《组合游戏略述——浅谈SG游...

dielie6462的博客 156

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU1536&&HDU1944 S-Nim SG函数

题目链接:HDU1536 S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7162    Accepted Submission(s): 3026 Problem Description Ar

teddywang 397

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

hdu1536 S-Nim

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 典型尼姆题,直接sg模板搞 之前mex设为int,怎么都TE过不了,看了讨论之后说设为bool就过了,但是我不知道为什么,是bool更快吗??? ac代码: 1 #include<cstdio> 2 #include<iostream> 3 #...

184

hdu1536 hdu1944 S-Nim

S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3527    Accepted Submission(s): 1551 Problem Description Arthur and his siste

习惯与规则决定命运 884

HDU 1536 S-Nim

师时隔几个月后,在看博弈NIM终于懂了,做出了第一道根据所有堆的异或和的题 题意:在一个Si容器中,输入可以行走的步数,然后在下面T组测试数据中,输入堆的情况 View Code #include<stdio.h> #include<algorithm> using namespace std; //数组超是开小了 还是开大了 int enab...

aysd68784的博客 90

hdu 1536 S-Nim

Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: The starting position has a number of heaps, all containing some, not necessarily equal, nu

温文尔雅 308

hdu1536S-Nim

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 题意:给定k个数s[1]~s[k],再给定多组数据,每组数据给定n个数字表示有n个正数a[1]~a[n],玩家每次可以从某一堆里减去一个s[j]。无法操作就输了。 分析:博弈中SG函数的经典应用。 代码: #include #include #include #include #includ

Fsss 520

HDU 1536 S-Nim (SG函数)

S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6364    Accepted Submission(s): 2712 Problem Description Arthur and his sister

随心丶而遇的博客 1712

HDU 1536 S-Nim

S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3178    Accepted Submission(s): 1406 Problem Description Arthur and his siste

忆梦 810

HDU1536/POJ2960 S-Nim

Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: * The starting position has a number of heaps, all containing some, not necessarily equal, number of beads. * The players take turns chos

dygxczn的博客 131
上一篇: HDU - 2509 Be the Winner
下一篇: HDU - 1846 Brave Game
我不会额
博客等级 码龄11年 2粉丝 173原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值