hdu3980 Paint Chain SG函数

步进电机 cia402协议 报文自己的理解 (笔记) 阅读详情

Problem Description
Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one player must paint a unpainted beads. Whoever is unable to paint in his turn lose the game. Aekdycoin will take the first move.

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.
 

Input
First line contains T, the number of test cases. Following T line contain 2 integer N, M, indicate the chain has N beads, and each turn one player must paint M consecutive beads. (1 <= N, M <= 1000)
 

Output
For each case, print "Case #idx: " first where idx is the case number start from 1, and the name of the winner.
 

Sample Input
2 3 1 4 2
 

Sample Output
Case #1: aekdycoin Case #2: abcdxyzk

  N个珠子,两个人轮流取连续M个,谁不能取了就输了。

  初步了解了一下SG函数,目前只会用,原理到时再研究。

  简单说就是找当前状态下一步的子状态,如果没有子状态当前sg为0,如果操作某一步后分成了多个子状态,则把他们的sg值异或,看成一个整体作为当前的一个子sg。当前sg的取值为他所有子sg里从0开始sg没有取到的那个值。

  对于这个题,就是记忆化搜索,求出当前状态的SG,判断是否为0。

  先操作一步,把环变成链,这样才能递归。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<cmath>
#define INF 0x3f3f3f3f
#define MAXN 1010
#define MAXM 20010
#define MAXNODE 4*MAXN
#define eps 1e-9
using namespace std;
int T,N,M,sg[MAXN];
int SG(int n){
    if(sg[n]!=-1) return sg[n];
    if(n<M) return sg[n]=0;
    int vis[MAXN]={0};
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n-M-i;i++) vis[SG(i)^SG(n-M-i)]=1;
    for(int i=0;;i++) if(!vis[i]) return sg[n]=i;
}
int main(){
    freopen("in.txt","r",stdin);
    scanf("%d",&T);
    int cas=0;
    while(T--){
        scanf("%d%d",&N,&M);
        printf("Case #%d: ",++cas);
        memset(sg,-1,sizeof(sg));
        if(N<M){
            printf("abcdxyzk\n");
            continue;
        }
        if(SG(N-M)) printf("abcdxyzk\n");
        else printf("aekdycoin\n");
    }
    return 0;
}


CT探测器普遍采用“星形拓扑+多ADC模组”架构的TDC(时间数字转换器)设计方案 本文提出一种基于TDC反馈机制的CT探测器时钟同步方法,通过延时测量、偏差计算和动态补偿三步硬件流水线,实现高精度同步。系统采用Xilinx Kintex UltraScale FPGA内置CARRY8进位链构建3.5ps分辨率的TDC,结合多级比较器和延迟单元,形成闭环反馈控制。实验表明,在512通道、1.28m传输距离下,同步精度稳定在10ps以内,较传统方案提升两个数量级,并能动态补偿干扰抖动。该方案解决了传统方法在CT旋转腔体环境下精度不足的问题,为下一代超高清CT提供了有效的时钟同步解决方案。 阅读详情

相关推荐

如何在SendWS实现WhatsApp批量群发设置管理?WhatsApp群发超链有什么好处?

WhatsApp群发顾名思义就是对WhatsApp上的用户好友进行群发消息,给他们群发想要发送的消息。及时不认识对方也可以对他进行群发超链。越来越多做跨境出海运营的工作者利用WhatsApp进行营销推广,因为他能做到低成本高回报,向客户发送消息曝光自己的品牌或产品,使得更多人了解,拓展新客户,提高成交率。

SendWS-WS云控群控拓客聊天翻译 1198

hdu 3980 Paint Chain(SG函数)

Paint ChainProblem DescriptionAekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each tur

Darkarts 1万+

Oracle EBS MRP 模块测试记录

MRP 模块测试记录        构思:创建Shirt成品物料,它由Cloth和Button组成。1*Shirt=1*Cloth+8*Button。        首先创建这三个物料(复制模板创建),并分配给T02。        创建BOM,将这三个物料关联起来。        分别创建资源(人工和设备)制造Cloth和Button。        分别创建两个部门(HumanDep和Mach

NetSuite 张老师 8200

hdu3980Paint Chain+SG博弈

Problem Description Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one pla

xtulollipop 1118

结构力学程序算法理论基础(一)————虚功原理

1.约束 定义约束:限制质点或者质点系运动的条件称为约束,表示这些限制条件的数学方程称为约束方程。 (1)几何约束 限制质点或者质点系在空间的几何位置的条件称为几何约束.如单摆,其中质点M可绕固定点O在平面Oxy内摆动,摆长为l.这时摆杆对质点的限制条件是:质点M必须在以点O为圆心,以l为半径的圆周上运动.其约束方程为: 又质点M在固定的曲面上运动,那么曲面方程就是质点M的约束方程,即 上...

l93919861的博客 4523

衡山派平台mini_audio_player模块接口设计与实现详解

本文详细解析了衡山派(ArtInChip)平台MPP中间件中的mini_audio_player音频播放模块。通过剖析其源码结构、核心数据状态机及非阻塞API设计,并结合官方Demo,指导开发者如何在嵌入式设备上高效集成该模块,实现MP3、WAV等音频文件的播放、暂停、音量控制等功能。

weixin_35677363的博客 533

HDU 3980 Paint Chain(博弈 SG)

HDU 3980 Paint Chain(博弈 SG)

1442

《手把手教你修复过期K8s集群证书:记一次K8s集群起死回生实录》

今天本想打开半年前部署的K8s测试集群跑个Demo,结果`kubectl`直接报错`certificate has expired`!作为一名云原生老司机,我决定把这次'抢救'过程记录下来,手把手带大家解决这个运维常见问题。

✨ 欢迎来到【Seal ^_^ 的CSDN博客】!✨ 3791

hdu3980 Paint Chain

Paint Chain Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 897 Accepted Submission(s): 316 Problem Description Aekdycoin and abcdxyzk are

习惯与规则决定命运 1001

【异常】Cursor IDE 扩展主机超时错误处理文档The agent execution provider did not respond within 4 seconds.

该错误通常是 Cursor IDE 的临时性问题,不影响项目代码。大多数情况下,重新加载窗口或重启 IDE 即可解决。如果问题持续,可按上述进阶方案排查。重新加载窗口(最快)重启 IDE检查系统资源清理缓存检查扩展更多关于 AI+教育领域的干货,可以关注我的微信公众号第一时间获取哦~

奶爸的编程之路,也就一周冷个三天 2747

图神经网络在金融风险传播分析中的应用

《图神经网络在金融风险传播分析中的应用》 摘要 本文旨在探讨图神经网络(Graph Neural Networks, GNN)在金融风险传播分析中的应用。首先,本文简要介绍了图神经网络的基本概念、发展历史以及其在各类应用场景中的重要性。接着,详细介绍了图神经网络的核心算法,包括图卷积神经网

AI天才研究院 1292

hdu 3980 Paint Chain 博弈+SG函数 每次选连续M个

Problem Description Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is pain

kongming_acm的专栏 905

Midscene.js(3):手把手教你用 YAML 脚本实现 AI 驱动的 Web UI 自动化「喂饭教程」

Midscene.js是一款开源的AI驱动UI自动化工具,通过自然语言描述即可控制浏览器或Android设备执行操作。它支持YAML脚本编写测试用例,降低了自动化测试门槛。

blues_C的博客 3265

hdu3980Paint Chain(博弈+SG函数)

hdu3980Paint Chain(博弈+SG函数) 先来说说SG函数的灵魂就是mex函数,这是一个针对于集合的函数,表示最小的不属于这个集合的非负整数。比如mex{1,2,3,4}=0;mex{0,2,3,4}=1; SG函数想要获取的就是mex{“计算出的集合”}; Problem Description Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none

濡苏的博客 541

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

HDU3980 Paint Chain SG函数

题目链接:HDU3980 Paint Chain Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1803    Accepted Submission(s): 629 Problem Description

teddywang 524

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

hdu 3980 Paint Chain 组合游戏 SG函数

题目链接 题意 有一个\(n\)个珠子的环,两人轮流给环上的珠子涂色。规定每次涂色必须涂连续的\(m\)颗珠子,无法继续操作的人输。问先手能否赢。 思路 参考 转化 第一个人取完之后就变成了一条链,现只需要考虑这条链上的操作即可。 SG函数计算 考虑在一个链上涂连续的\(m\)颗珠子这个问题的子问题,记当前有\(x\)颗珠子 \(x\lt m\) 显然已经无法涂了,故\(sg(x)=0\...

ahu12345678的博客 124

IDEA的使用指南

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

HDU 3980 Paint Chain(sg函数)

Problem DescriptionAekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one play...

←_← 281

HDU - 3980 Paint Chain(sg函数)

Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one player must paint a unp...

Cymbals的博客 353

HDU 3980 Paint Chain(SG函数)

Problem Description: Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one p

蘑菇--走在通往梦想的道路上。 723

HDU---3980:Paint Chain【SG函数】

题意: 两个人轮流给有N个玻璃球的环涂色,每次只能给一段长为M的子段且没有涂过色的玻璃球涂色,不能操作者输 分析: SG函数: SG[x] = mex{SG[y] | y为x能到达的后继点},mex{}返回在自然数中第一个未出现的数,mex{0,1,3,4} = 2;SG[x] = 0,则x为必败点,否则x为必胜点 SG定理: 子游戏SG值的异或和等于全局的SG值 NIM...

KobeDuu 218

HDU3980 Paint Chain(SG函数)

传送门 nnn个点围成一个环,每次每个人可以把连续的mmm个点染色 无法操作的人失败, 问胜负情况 很明显第一个人操作过后,环就变成了一条链 所以可以定义sg[x]sg[x]sg[x]为链长xxx的sgsgsg值 那么显然sg[k]=0 (k∈[0,m−1])sg[k]=0\ (k\in[0,m-1])sg[k]=0 (k∈[0,m−1]) 然后枚举先手第一次把链变成长n−mn-mn−m 所以我们求sg[n−m]sg[n-m]sg[n−m]是后手的胜负状态 注意特判n<mn&lt

jziwjxjd的博客 491

HDU 3980 Paint Chain (sg函数)

Paint Chain Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 804    Accepted Submission(s): 292 Problem Description Aekdycoin and abcdxyzk are...

weixin_34233856的博客 91

HDU 3980 Paint Chain(博弈论,SG函数)

#include<bits/stdc++.h> using namespace std; const int maxn = 1005; int sg[maxn]; int grundy(int n, int m) { if(sg[n] != -1) { return sg[n]; } if(n < m) { return sg[n] = 0; } int ...

Nerdant 438

HDU - 3980-Paint Chain(博弈,SG函数)

题目链接:HDU - 3980-Paint Chain Paint Chain Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2223 Accepted Submission(s): 814 Problem Descrip...

howell 373

hdu 3980 Paint Chain (sg函数 )

Problem Description Aekdycoin and abcdxyzk are playing a game. They get a circle chain with some beads. Initially none of the beads is painted. They take turns to paint the chain. In Each turn one pla

退役的铜牌狗 497

HDU - 3980 Paint Chain(SG函数)

https://vjudge.net/problem/HDU-3980 题意 一串长度为n的柱子,每个人只能给连续的珠子涂色,涂过的不能再涂,不能涂的人就输了,问最后谁获胜。 分析 第一个人先涂m个,就把环变成链了,先手就变为后手。现在考虑长度为N-M的链上的游戏,用子状态来推出当前状态,一个问题的结果是其子问题的结果的亦或,然后使用记忆化推出sg,就知道谁赢了。 #include...

weixin_33806914的博客 177
上一篇: hdu 3972 1 M possible
下一篇: uva11806 - Cheerleaders 容斥原理
小小小小葱
博客等级 码龄14年 22粉丝 266原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址