Hdu 1536 S-Nim

28-基于STM32单片机的便携式健康监测系统设计与实现(程序+原理图+元件清单) 本文详细介绍了基于STM32单片机的便携式健康监测系统设计与实现,该系统集成MAX30102光电传感器和MSP20压力传感器,实时监测心率、血氧和血压等关键生理指标。通过STM32F103C8T6主控芯片和HC-05蓝牙模块,实现数据采集、处理及无线传输,具有便携性高、操作简便等特点,适用于家庭健康监护和户外运动场景。 阅读详情

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. 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 chosing a heap and removing a positive number of beads from it.

  The first player not able to make a move, loses.


Arthur and Caroll really enjoyed playing this simple game until they recently learned an easy way to always be able to find the best move:


  Xor the number of beads in the heaps in the current position (i.e. if we have 2, 4 and 7 the xor-sum will be 1 as 2 xor 4 xor 7 = 1).

  If the xor-sum is 0, too bad, you will lose.

  Otherwise, move such that the xor-sum becomes 0. This is always possible.


It is quite easy to convince oneself that this works. Consider these facts:

  The player that takes the last bead wins.

  After the winning player's last move the xor-sum will be 0.

  The xor-sum will change after every move.


Which means that if you make sure that the xor-sum always is 0 when you have made your move, your opponent will never be able to win, and, thus, you will win.

Understandibly it is no fun to play a game when both players know how to play perfectly (ignorance is bliss). Fourtunately, Arthur and Caroll soon came up with a similar game, S-Nim, that seemed to solve this problem. Each player is now only allowed to remove a number of beads in some predefined set S, e.g. if we have S =(2, 5) each player is only allowed to remove 2 or 5 beads. Now it is not always possible to make the xor-sum 0 and, thus, the strategy above is useless. Or is it?

your job is to write a program that determines if a position of S-Nim is a losing or a winning position. A position is a winning position if there is at least one move to a losing position. A position is a losing position if there are no moves to a losing position. This means, as expected, that a position with no legal moves is a losing position.
 

Input
Input consists of a number of test cases. For each test case: The first line contains a number k (0 < k ≤ 100 describing the size of S, followed by k numbers si (0 < si ≤ 10000) describing S. The second line contains a number m (0 < m ≤ 100) describing the number of positions to evaluate. The next m lines each contain a number l (0 < l ≤ 100) describing the number of heaps and l numbers hi (0 ≤ hi ≤ 10000) describing the number of beads in the heaps. The last test case is followed by a 0 on a line of its own.
 

Output
For each position: If the described position is a winning position print a 'W'.If the described position is a losing position print an 'L'. Print a newline after each test case.
 

Sample Input
  
2 2 5 3 2 5 12 3 2 4 7 4 2 3 7 12 5 1 2 3 4 5 3 2 5 12 3 2 4 7 4 2 3 7 12 0
 

Sample Output
  
LWW WWL
 

Source
Norgesmesterskapet 2004

SG函数+组合游戏定理

#include<cstdio>
#include<cstring>

int num[110];
int SG[11000];
int k;

void dfs(int x)
{
    int i;
    int vis[110];
    memset(vis,0,sizeof(vis));
    for(i=1;i<=k;i++)
    {
        if(x-num[i]>=0)
        {
            if(SG[x-num[i]]==-1)
                dfs(x-num[i]);
            vis[SG[x-num[i]]]=1;
        }
    }

    for(i=0;i<110;i++)
    {
        if(vis[i]==0)
        {
            SG[x]=i;
            return ;
        }
    }
}

int main()
{
    int t,x,flag,n;
    int i;

    while(scanf("%d",&k),k)
    {
        for(i=1;i<=k;i++)
        {
            scanf("%d",&num[i]);
        }
        
        memset(SG,-1,sizeof(SG));
        scanf("%d",&t);
        while(t--)
        {
            flag=0;
            scanf("%d",&n);
            SG[0]=0;
            for(i=1;i<=n;i++)
            {
                scanf("%d",&x);
                if(SG[x]==-1)
                    dfs(x);
                flag^=SG[x];
            }
            if(flag==0)
                printf("L");
            else
                printf("W");
        }
        printf("\n");
   }
    return 0;
}


请尽可能地详细说明一个VLA项目的立项训练到落地的全流程 一个机器人VLA项目的全流程是一个复杂的系统工程,它深度融合了机器人学 (Robotics)计算机视觉 (CV)和自然语言处理 (NLP)。其核心挑战在于高质量数据的获取和从仿真到现实的有效迁移。与纯粹的软件AI项目相比,它增加了硬件、物理交互和安全性的维度,但其最终能让AI走出虚拟世界、在物理世界中产生实际价值,这也是其巨大的魅力所在。 阅读详情

相关推荐

Allegro PCB位号重排反标原理图步骤

allegro操作技巧

qq_36033382的博客 2880

s-nim(一道很麻烦的题)

首先会输入一个n 代表有n种抽牌方式,紧接着n个数字输入; 然后是m表示有m组数据需要判断在这n种抽牌方式下第一个抽牌的人是输或是赢 最后输出m个L/W(这里不太会处理,直接用数组存了) 最后输入0表示输入结束 需要注意的就是需要将n种抽牌方式进行从小到大的排序,不然sg函数中的break要改为continue, 还有就是sg函数的写法需要熟练 #include<iostream> #include<cstring> #include<algorithm> u

pruuu____d的博客 390

新手必看:LiteRadio 2c SE遥控器从开箱到飞行的完整指南(附常见问题解答)

本文为新手提供LiteRadio 2c SE遥控器的完整使用指南,涵盖从开箱到首飞的20个关键步骤。详细介绍了遥控器的功能设置、与无人机的对频技巧以及首飞注意事项,帮助用户快速掌握飞行控制,避免常见错误。特别适合无人机初学者阅读。

weixin_29209801的博客 388

S-Nim + sg函数+博弈+模板

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

wenlovingliu的专栏 760

Xilinx PL实现DP TX视频传输的关键配置与实战解析

本文详细解析了在Xilinx ZCU106开发板上,利用PL(可编程逻辑)实现DP TX(DisplayPort发送)视频传输的关键配置与实战流程。内容涵盖从硬件平台搭建、DP TX IP核参数(如链路速率、通道数、视频时序)的详细配置,到软件驱动初始化、中断处理及链路训练的全过程,并提供了屏幕闪烁、颜色异常等常见问题的避坑指南与调试技巧,旨在帮助开发者高效实现稳定的4K视频输出。

weixin_29165465的博客 356

KV STUDIO的安装与实践(一)

KV STUDIO是一种软件开发工具,用于编写、调试和管理基于Key-Value(键-值)存储的应用程序。KV STUDIO提供了一个集成开发环境(IDE),使开发人员可以方便地创建和管理键-值数据库,并编写逻辑和业务规则来操作和查询这些数据。它支持多种编程语言和平台,并提供了丰富的API和工具来简化开发过程。使用KV STUDIO,开发人员可以快速构建高效、可靠的键-值存储系统,并实现各种应用程序,如缓存、会话管理、配置存储等。本次使用plc进行案例讲解,结合小编的亲身经历,仅供参考!

weixin_47514459的博客 6441

【算法】博弈论

算法

gyk038的博客 172

结构力学仿真软件:STAAD.Pro:结构抗震设计与STAAD.Pro应用_2024-08-10_11-49-29.Tex

STAAD.Pro是一款广泛应用于结构工程领域的仿真软件,由Bentley Systems开发。它能够进行结构分析和设计,支持多种结构类型,包括桥梁、建筑物、塔架等。STAAD.Pro提供了强大的建模工具,用户可以轻松创建复杂的结构模型,并进行静态和动态分析。软件还支持多种载荷组合,包括地震载荷,以及提供详细的报告和图纸输出,便于工程师进行设计和审查。STAAD.Pro是一款广泛应用于结构工程设计的软件,其界面直观,功能强大,能够进行结构分析与设计。菜单栏。

987

博弈论入门(Game Theory)

博弈论(Game Theory)一、巴什博弈(Bash Game)操作:代码:例题:1.Brave Game2. kiki's game二、威佐夫博弈(Wythoff Game)操作:代码:例题:1.取石子游戏三、尼姆博弈论(Nim Game)操作:代码:例题:1. Being a Good Boy in Spring Festival四、斐波那契博弈论操作:代码:例题:1. 取石子游戏五、SG函数操作:代码:例题:1. Good Luck in CET-4 Everybody!2. S-Nim 一、巴什博

Hayleyzhou的博客 2725

ultralytics.data.utils——utils.py子模块代码详读

ultralytics.data.utils——utils.py子模块代码详读

Together_CZ的博客 1734

风电光伏功率预测竞赛精华总结:技术解析与实战经验

本文深度解析新能源功率预测竞赛的技术要点与实战经验。首先介绍了风电、光伏功率预测对电网调度优化、降低运营风险的重要性,以及多个竞赛的基本概况。在数据特征分析部分,详细探讨了气象预报数据和功率数据的特征,包括时间周期性、数据质量问题及处理方法。针对异常值检测、数据标准化和特征工程(如时间特征、统计聚合特征、风速风向特征和滞后特征)提供了具体的技术实现方案。文章为新能源功率预测提供了实用的技术指导,对相关竞赛和实际应用具有重要参考价值。

算法工程师 219

博弈论SG函数-算法介绍及例题

一、 基本概念: 1. Impartial Combinatorial Games(ICG) 公平组合游戏: 1. 两名选手 2. 交替进行某种游戏规定的操作,每操作一次,选手可以在有限的操作(操作必须合法)集合中任选一种。 3. 对于游戏的任何一种可能的局面,合法操作集合只取决于这个局面本身,不取决于其它因素(跟选手,以前的所有操作无关) 4. 如果...

Gaoithe的博客 2407

量化交易 米筐 多因子合成(回测中使用)

多因子合成 1、因子合成 将一些相关(高、低)的因子合成一个因子 方法: 使用PCA方式(使用于较强相关性) 2、核心代码 将因子 inc_revenue_ttm 和 operating_revenue_growth_ratio_ttm 合成为一个因子 inc_operating from sklearn.decomposition import PCA pca = PCA(n_components=1) # 因子合并 fund['inc_operating'] = pca.fit_transform(fu

廷益_飞鸟的博客 1068

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

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

【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

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

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

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

【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

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

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

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

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

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
上一篇: Hdu 1907 John
下一篇: Hdu 1729 Stone Game
Magic_____
博客等级 码龄14年 11粉丝 160原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址