![](https://img-blog.csdnimg.cn/20190905201825696.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
博弈
Ray.C.L
不开longlong见祖宗
展开
-
AcWing 894 拆分nim游戏(求sg函数)
思路:问你放两堆规模更小的石子,sg(bi,bj)=sg(bi)^sg(bj) #include <cstdio> #include <cstring> #include <algorithm> #include <set> #include<bits/stdc++.h> using namespace std; typedef long long ll; #define space putchar(' ') #define enter putc.原创 2020-05-13 12:42:18 · 256 阅读 · 0 评论 -
AcWing 893集合nim游戏(求SG函数)
思路:记忆化搜索求SG函数O(N*K) #include <cstdio> #include <cstring> #include <algorithm> #include <set> #include<bits/stdc++.h> using namespace std; typedef long long ll; #define space putchar(' ') #define enter putchar('\n') typedef pa.原创 2020-05-13 12:05:39 · 181 阅读 · 0 评论 -
AcWing 832 台阶nim游戏
思路:台阶Nim游戏是普通的Nim博弈的进阶版,最后的输赢与奇数台阶上的石子有关。如果后手移动偶数阶的石子,那么先手将后手移动到奇数阶的石子再次移动,就可以发现偶数阶的石子对博弈是没有影响的。如果后手移动奇数阶的石子,先手同样移动奇数阶的石子。当奇数阶上没有石子时,由于先手走最后一步,所以此时后手只能移动偶数阶上的石子,先手将后手移动的石子再移动一次,就一定可以取胜。 #include <cstdio> #include <cstring> #include <algorit.原创 2020-05-13 11:20:57 · 152 阅读 · 0 评论 -
Be the Winner(反尼姆博弈)
Let’s consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time. For example “@@@” can be turn...原创 2019-08-16 18:25:10 · 361 阅读 · 0 评论 -
Matrix Game(尼姆博弈变形)
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 given. For example, let there be a 2 x 3 matrix, and the piles are 2 ...原创 2019-08-16 18:34:22 · 496 阅读 · 0 评论 -
Partitioning Game (博弈sg函数)
Alice and Bob are playing a strange game. The rules of the game are: Initially there are n piles. A pile is formed by some cells. Alice starts the game and they alternate turns. In each...原创 2019-08-16 19:47:32 · 169 阅读 · 0 评论