lightoj 1020 (博弈)】的更多相关文章

lightoj 1020 A Childhood Game 链接:http://lightoj.com/volume_showproblem.php?problem=1020 题意:一堆石子有 m 个,Alice和Bob可以从中取1个或者2个,如果Alice先取,最后取的人败:如果Bob先取,最后取的人胜.问胜利者. 思路:枚举前几个石子的情况,很容易找出每种情况的必败点,找规律.如果Alice先取,Alice的必败点为mod 3 == 1,如果Bob先取,Bob必败点在 mod 3 == 0处…
题目链接: 1020 - A Childhood Game 题目描述: Alice和Bob在玩弹珠游戏,两人轮流拿走弹珠,每次只能拿走一个或者两个,当Alice作为先手时谁拿走最后一个就是输家,而Bob作为先手时谁拿走最后一个就是赢家,问最后谁是赢家? 解题思路: 很基础的博弈题目,我们可以知道当Alice作为先手的时候:n=1(Alice lose), n=2(Alice win), n=3(Alice win), n=4(Alice lose), n=5(Alice win). 从上面可以看…
思路:很简单的博弈,找出每个人先拿的必胜态进行状态转移即可. #include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main(){ int t, n, CASE(0); char str[10]; scanf("%d", &t); while(…
Allice先拿,最后拿球的输. Bob先拿,最后拿球的赢. 考虑Alice先拿球,当n=1时 Alice输  记dp[1]=0; n=2,  dp[2]=1 n=3,  dp[3]=1 因为n=1,2的时候先手是A,所以A可以通过选一个还是两个球使得B在n=2,3时输. n=4,  dp[4]=0 因为n=2,3时B可能是先手,所以B可以通过选一个还是两个球使得A在n=4的时候输. n=5,dp[5]=1; n=6,dp[6]=1; 因为n=4,5的时候先手是A,所以A可以通过选一个还是两个球…
A - Matrix Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Given an m x n matrix, where m denotes the number of rows and n denotes the number of columns and in each cell a pile of stones is gi…
题意: 给一个矩阵,每一次一个玩家可以从任意一行中选任意数量的格子并从中拿石头(但最后总数要大于等于1),问你谁赢 思路: 一开始以为只能一行拿一个... 将每一行石子数相加就转化为经典的Nim博弈 代码: #include<cstdio> #include<iostream> #include<algorithm> const int N = 100000+5; const int INF = 0x3f3f3f3f; using namespace std; int…
Jolly and Emily are two bees studying in Computer Science. Unlike other bees they are fond of playing two-player games. They used to play Tic-tac-toe, Chess etc. But now since they are in CS they invented a new game that definitely requires some know…
Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, each pile containing one or more stones. The players alternate turns and in each turn a player can select one of the piles and can remove as many stones…
You are given an n x n chess board. Only pawn is used in the 'Incredible Chess' and they can move forward or backward. In each column there are two pawns, one white and one black. White pawns are placed in the lower part of the board and the black pa…
主要是写一下nim博弈的理解,这个题有点奇怪,不知道为什么判断奇偶性,如果有大佬知道还请讲解一下. //nim博弈 //a[0]~a[i] 异或结果为k 若k=0 则为平衡态 否则为非平衡态 //平衡态转化为非平衡态 :一定有 a[n]^k<a[n] a[0]^--a[n]^k--^a[i]=0 //二进制为什么能判断平衡态 并且转化 将每一对转化为二进制的小堆 /*,每个正整数都有对应的一个二进制数, 例如:57(10)à 111001(2) ,即:57(10)=25+24+23+20. 于是…