Uva 1378 - A Funny Stone Game】的更多相关文章

题目链接:uva 1378 - A Funny Stone Game 题目大意:两个人玩游戏,对于一个序列,轮流操作.每次选中序列中的i,j,k三个位置要求i<j≤k,然后arr[i]减1,对应的arr[j]和arr[k]加1,不能操作的人输,问先手是否必胜.必胜的话给出字典序最下的必胜方案.负责输出-1. 解题思路:首先预处理出各个位置上的SG值,然后对于给定序列,枚举位置转移状态后推断是否为必败态就可以. #include <cstdio> #include <cstring&…
1378 - A Funny Stone Game Time limit: 3.000 seconds The funny stone game is coming. There are n piles of stones, numbered with 0, 1, 2,..., n - 1. Two persons pick stones in turn. In every turn, each person selects three piles of stones numbered i, j…
A Funny Stone Game 题意: $n \le 23$堆石子,每次选择$i < j \le k$,从$i$拿走1颗$j,k$各放入一颗,不能取就失败.求先手是否必胜以及第一次取的策略 一开始一直在想游戏怎么会结束...眼残没发现$i<j.....$ 然后,解这类组合游戏问题重要的一步是发现独立的子游戏 本题中每个石子是互不影响的 $sg[i]$为一颗在$i$的石子的状态 $sg[i]=mex\{sg[j] \oplus sg[k]\}$ 然后就$\oplus$起来就行了 #incl…
题目链接:http://vjudge.net/problem/viewProblem.action?id=41555 把第i堆的每个石子看出一堆个数为n-i的石子,转换为组合游戏 #include <stdio.h> #include <algorithm> #include <stdlib.h> #include <cstring> using namespace std; #define N 30 int a[N],sg[N]; void cal_sg(…
题意:David 玩一个石子游戏. 游戏中,有n堆石子,被编号为0..n-1.两名玩家轮流取石子. 每一轮游戏.每名玩家选取3堆石子i,j,k(i<j,j<=k,且至少有一枚石子在第i堆石子中). 从i中取出一枚石子,并向j.k中各放入一枚石子(假设j=k则向k中放入2颗石子). 最 先不能取石子的人输. 石子堆的个数不会超过23.每一堆石子不超过1000个. 解法:看上去是将石子都往右移,直到全部都到了n-1堆不能移为止. 首先是考虑每堆石子事实上是独立的一个子游戏,堆与堆之间不相互影响.…
option=com_onlinejudge&Itemid=8&page=show_problem&problem=4342">题目链接:uva 1567 - A simple stone game 题目大意:给定K和N.表示一堆石子有N个.先手第一次能够取1~N-1个石子,取到最后一个石子的人胜利,单词每次操作时,取的石子数不能超过对手上一次取的石子数m的K倍. 问先手能否够必胜.能够输出最小的首次操作. 解题思路:这题想了一天,又是打表找规律.又是推公式的,楞是…
说明:关于Uva的题目,可以在vjudge上做的,不用到Uva(那个极其慢的)网站去做. 最小瓶颈路:找u到v的一条路径满足最大边权值尽量小 先求最小生成树,然后u到v的路径在树上是唯一的,答案就是这条路径. Uva 534 Frogger Time Limit: 3000MS 64bit IO Format: %lld & %llu Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly h…
UVA 10165 - Stone Game 题目链接 题意:给定n堆石子,每次能在一堆取1到多个.取到最后一个赢,问谁赢 思路:就裸的的Nim游戏,利用定理求解 代码: #include <stdio.h> #include <string.h> int n, num; int main() { while (~scanf("%d", &n) && n) { int sum = 0; for (int i = 0; i < n;…
UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题) Description Let's play a stone removing game. Initially, n ston…
POJ 2235 Frogger / UVA 534 Frogger /ZOJ 1942 Frogger(图论,最短路径) Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty a…