题目链接 n堆石子, 可以拿走一堆中的一颗, 或者将一堆数量为2*x的石子分为k堆x个的石子.k由题目给出. k分奇偶讨论. k为偶数时,k堆x个的石子异或结果为0: k为奇数时, k堆x个石子异或结果与mex(x)相等, 然后打不同的sg表找规律, 打表程序看代码. #include<bits/stdc++.h> using namespace std; #define pb(x) push_back(x) #define ll long long #define mk(x, y) make…
Lieges of Legendre 题意:有n堆牛,每堆有ai头牛.两个人玩一个游戏,游戏规则为: <1>从任意一个非空的堆中移走一头牛: <2>将偶数堆2*x变成k堆,每堆x头牛(可以增加牛的个数) 移走最后一头牛的人获胜: 数据:n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109).a1, a2, ... an (1 ≤ ai ≤ 109) 分析:这显然是SG函数与SG定理的应用: SG函数与SG定理:SG[x] = mex(S);其中S是所有x的后继…
C. Lieges of Legendre 题意:给n,m表示有n个为2的倍数,m个为3的倍数:问这n+m个数不重复时的最大值 最小为多少? 数据:(0 ≤ n, m ≤ 1 000 000, n + m > 0) ps:很水的题,主要是策略: 思路:由于里面每隔6就会重复一次,不好直接模拟,并且模拟的效率很低,那就二分吧!二分即上界为2单独的最大倍数与3单独时的最大倍数之和,下界为前面二者的max;之后利用判断是否mid/2 >= n && mid/3 >= m &am…
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. T…
#include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while(t--){ int n,k; cin>>n>>k; if(k%3==0){ n%=(k+1); if(n==k||n%3) cout<<"Alice"<<"\n"; else cout<<"Bob&…
C. Lieges of Legendre time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying…
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)…
转自:http://chensmiles.blog.163.com/blog/static/12146399120104644141326/ http://blog.csdn.net/xiaofengcanyuexj/article/details/17119705 SG函数 “Sprague-Grundy函数” 我们将面对更多与Nim游戏有关的变种,还会看到Nim游戏的a1^a2^...^an这个值更广泛的意义. 上面的文章里我们仔细研究了Nim游戏,并且了解了找出必胜策略的方法.但如果把Ni…
对于Nim博弈,任何奇异局势(a,b,c)都有a^b^c=0. 延伸: 任何奇异局势(a1, a2,… an)都满足 a1^a2^…^an=0 首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最小的不属于这个集合的非负整数. 例如mex{0,1,2,4}=3.mex{2,3,5}=0.mex{}=0. 对于一个给定的有向无环图,定义关于图的每个顶点的Sprague-Garundy函数g如下: g(x)=mex{ g(y) | y是x的后继 }. SG函数性…
A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Description Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The…