hdu 3032 Nim or not Nim? sg函数 难度:0】的更多相关文章

Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1056    Accepted Submission(s): 523 Problem Description Nim is a two-player mathematic game of strategy in which players take turn…
Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2766    Accepted Submission(s): 1594 Problem Description Adam and Eve enter this year’s ACM International Collegiate Programming Con…
S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4770    Accepted Submission(s): 2058 Problem Description Arthur and his sister Caroll have been playing a game called Nim for some time now.…
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3832    Accepted Submission(s): 2183 Problem Description Stan and Ollie play the game of multiplication by multiplying an in…
A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player who picks the last one will win the game.On each turn they can pick any number of candies which come from the same heap(picking no candy is not allowed)…
Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10069    Accepted Submission(s): 4289 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2)(n>=3);…
提议分析: 1 <= N <= 4747 很明显应该不会有规律的,打表发现真没有 按题意应该分成两种情况考虑,然后求其异或(SG函数性质) (1)找出单独的一个(一列中只有一个) (2)找出连续的两个都没有涂色的求SG值(打表) #include<stdio.h> #include<string.h> #define Max 4750 int dp[Max]; int mex[Max]; int flag[Max]; void Gsdp() { int i,j; int…
题目链接 题意 有一个\(n\)个珠子的环,两人轮流给环上的珠子涂色.规定每次涂色必须涂连续的\(m\)颗珠子,无法继续操作的人输.问先手能否赢. 思路 参考 转化 第一个人取完之后就变成了一条链,现只需要考虑这条链上的操作即可. SG函数计算 考虑在一个链上涂连续的\(m\)颗珠子这个问题的子问题,记当前有\(x\)颗珠子 \(x\lt m\) 显然已经无法涂了,故\(sg(x)=0\). \(x\geq m\) 设左边有\(i\)颗珠子,则右边有\((m-i)\)颗珠子.则该子问题的\(sg…
传送门 题意: 有三堆石子,双方轮流从某堆石子中去f个石子,直到不能取,问先手是否必胜,其中f为斐波那契数. 思路: 利用SG函数求解即可. /* * @Author: chenkexing * @Date: 2019-01-13 16:17:46 * @Last Modified by: chenkexing * @Last Modified time: 2019-01-15 11:10:33 */ #include <algorithm> #include <iterator>…
题意:一个N个点的拓扑图,有M个棋子,两个人轮流操作,每次操作可以把一个点的棋子移动到它的一个后继点上(每个点可以放多个棋子),直到不能操作,问先手是否赢. 思路:DFS求每个点的SG值,没有后继的点为必败点. 注意搜索中初始化的问题. #include<stdio.h> #include<string.h> ,M=N*N; struct node{ int v,next; }e[M]; int head[N],cnt,in[N],out[N],n,sg[N],p[N]; void…