
博弈论
文章平均质量分 53
Cymbals
Public void effect()
展开
-
Nim-硬币游戏1(Java)
Alice和Bob在玩这样一个游戏。给定k个数字a[1],a[2],…,a[k]。一开始,有x枚硬币,Alice和Bob轮流取硬币。每次所取硬币的枚数一定要在a[1],a[2],…,a[k]当中。Alice先取,取走最后一枚硬币的一方获胜。当双方都采取最优策略时,谁会获胜?题目假定a[1],a[2],…,a[k]中一定有1。 限制条件: 1<=x<=10000 1<=k&l...原创 2018-02-08 17:14:12 · 827 阅读 · 0 评论 -
Nim-硬币游戏2(Java)
n堆硬币,每堆各有xi枚硬币。给定k个数字 a1,a2,a3,…,ak。两人轮流选出一堆硬币,从中取出一些硬币。每次所取硬币枚数一定要在a1,a2,a3,…,ak中。 模板题,贴上java代码 public class Main { public static void main(String[] args) { Scanner reader = new Scann...原创 2018-02-13 20:33:34 · 627 阅读 · 0 评论 -
poj 2960 S-Nim(Java)
这题题目贼长……. 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 necessar...原创 2018-02-17 02:00:38 · 266 阅读 · 0 评论 -
回过头看HDU 5011 Game(2014西安区域赛)
Here is a game for two players. The rule of the game is described below: ● In the beginning of the game, there are a lot of piles of beads. ● Players take turns to play. Each turn, player choose a...原创 2018-02-18 22:39:43 · 253 阅读 · 0 评论 -
2018徐州网络赛-菜鸡补题
I.Characters with Hash 签到题。消掉前缀零,特判一下差小于10的情况和全0的情况即可。 ac代码: #include<bits/stdc++.h> using namespace std; char p, s[1000005]; int main() { int t, n; scanf("%d", &t); while(t...原创 2018-09-11 18:14:18 · 337 阅读 · 0 评论 -
【男人八题】 A.String Game(后缀自动机 + sg函数)
题目:https://nanti.jisuanke.com/t/24852 题目大意:给一个模式串和n个它的子串,Alice和Bob玩游戏,Alice先手,每回合任选一个子串,该回合轮到的人在它后面加一个字母,并且保证加了之后的新串仍然是模式串的子串。轮到后没办法保证上述添加要求的人输。 (虽然题目没有说,但是字符集是小写字母) 可以看出这其实是一个经典的n堆nim博弈,可以用每个子串的sg函数异...原创 2018-10-19 14:41:49 · 801 阅读 · 0 评论 -
Gym - 101908B Marbles(sg函数)
题目:https://vjudge.net/contest/263079#problem/B 题目大意:两人玩游戏,棋盘上散布一些石头,谁先将其中任意一块移动到坐标(0,0)即赢,石头可以向左下角、左、下三个方向任意距离移动,求先手玩家的胜负。 这个游戏很显然可以用有向图表示,思考用sg函数求解。 但是有一些特殊情况并不能被sg表示。那就是x坐标轴、y坐标轴和x = y的轴上,这三条轴刚好符合了游...原创 2018-10-20 12:03:43 · 715 阅读 · 0 评论 -
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...原创 2018-10-23 20:13:33 · 289 阅读 · 0 评论