hdu 4155 The Game of 31 博弈论】的更多相关文章

给出序列,在剩下的卡中选择,谁先拿到大于31的输,搜一下就可以了! 代码如下: #include<cstdio> #include<cstring> ]; ],sum; bool dfs(int m) { ) ; ;i<=;i++){ ){ a[i]--; if(!dfs(m+i)){ a[i]++; ; } a[i]++; } } ; } int main() { while(scanf("%s",str)!=EOF){ int l=strlen(str…
取石子游戏 Problem Description 1堆石子有n个,两人轮流取.先取者第1次能够取随意多个,但不能所有取完.以后每次取的石子数不能超过上次取子数的2倍.取完者胜.先取者负输出"Second win".先取者胜输出"First win".   Input 输入有多组.每组第1行是2<=n<2^31. n=0退出.   Output 先取者负输出"Second win". 先取者胜输出"First win&quo…
思路:状态最多有2^12,采用记忆化搜索!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define inf 1<<30 using namespace std; ]={{,},{,},{,…
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #define M 1000000 #define ll __int64 using namespace std; ]; int get_len(int n) { ) ; ) ; ) ; ) ; ) ; ; } void solve(int n…
很经典的问题,思路转载自http://blog.csdn.net/ACM_cxlove?viewmode=contents 题目:这是一个经典问题,有n个海盗,分m块金子,其中他们会按一定的顺序提出自己的分配方案,如果50%以上的人赞成,则方案通过,开始分金子,如果不通过,则把提出方案的扔到海里,下一个人继续. 首先我们讲一下海盗分金决策的三个标准:保命,拿更多的金子,杀人,优先级是递减的.   同时分为两个状态稳定状态和不稳定状态:如果当n和m的组合使得最先决策的人(编号为n)不会被丢下海,…
看了解题报告才知道怎么做!! 题意:有 N 堆石子和 M 个石子回收站,每回合操作的人可以选择一堆石子,从中拿出一些 放到石子回收站里(可以放进多个回收站,每个回收站可以使用无数次),但每个石子回收站每次 只能接收特定数量的石子.不能操作的输.如果有人操作完之后,有任意一堆石子无法完全回收, 那么他直接输. 一个显然的结论是,每个游戏的 SG 值就是用 M 个回收站,完全回收这堆石子可行的最大 操作次数.由于最大的 Bi 比较小,立方暴力背包即可(比较显然的是,maxBi2 以上的周期是 min…
 这题是Lasker’s Nim. Clearly the Sprague-Grundy function for the one-pile game satisfies g(0) = 0 and g(1) = 1. The followers of 2 are 0, 1 and (1,1), with respective Sprague-Grundy values of 0, 1, and 1⊕1 = 0. Hence, g(2) = 2. The followers of 3 are 0,…
找sg值,可以选择暴力,也可以利用sg值的特点简化. 暴力就跟取石子一样,没什么差别,DFS搞定.把矩阵看成一个字符串,字符串就是一个状态. 其实我们也可以不暴力求sg值,因为只要当前状态能到达一个sg值为0的点,当前状态就是必胜点. 若当前点到达的所有状态都是必胜的,那么当前点就是必败点.所以当我们到达必胜点时,就必须转换当前状态继续递归找sg值. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm&g…
题目链接 //求三堆石子的SG函数,异或起来就是整个游戏的SG值 #include <cstdio> #include <cstring> const int N=1005; int n,m,p,cnt,F[N],sg[N+2]; bool vis[N+2]; void Init() { F[0]=F[1]=1; for(cnt=2; F[cnt-1]<N*2; ++cnt) F[cnt]=F[cnt-2]+F[cnt-1]; for(int i=1; i<N; ++i…
Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numbers from the greater of the two numbers, provided that the resulting number must be nonnegative…
题意: 有两个人从N个石子堆中拿石子,其中一个人可以拿两次,第二个人只能拿一次.最后拿完的人胜利. 思路: 类型 Hakase先 Hakase后 1 W L 1 1 W W 1 1 1 (3n) L W 1 1 1 1 (3n+1) W L 1 1 1 1 1 (3n+2) W W 类型 Hakase先 Hakase后 X 1 1 W L X Y 1 W W X Y Z W W X 1 1 1 W L X Y 1 1 W W X Y Z 1 W W X 1 1 1 1 W W X Y 1 1 1…
Primitive Roots   Description We say that integer x, 0 < x < n, is a primitive root modulo n if and only if the minimum positive integer y which makes x y = 1 (mod n) true is φ(n) .Here φ(n) is an arithmetic function that counts the totatives of n,…
只有代码: # ************************************************************ # Sequel Pro SQL dump # Version # # http://www.sequelpro.com/ # https://github.com/sequelpro/sequelpro # # Host: ) # Database: icoachu # Generation Time: :: # **********************…
Meeting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5512 Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two…
朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description B君在围观一群男生和一群女生玩游戏,具体来说游戏是这样的:给出一棵n个节点的树,这棵树的每条边有一个权值,这个权值只可能是0或1. 在一局游戏开始时,会确定一个节点作为根.接下来从女生开始,双方轮流进行 操作.当一方操作时,他们需要先选择一个不为根的点,满足该点到其父亲的边权为1; 然…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 题目大意: 4种棋子,象棋中的 1王,2车,3马,4后,选其一,B和G轮流走,不能往左上走,一开始棋子在(1,1),谁先走到(n,m)谁赢,无法走动算平局D. (n,m<=1000,case<=1000) 题目思路: [博弈论] 这题博弈论.怎样都输为必败,只能走到必败的为必胜. 王:(王可以横竖斜走一格)如果n个m均为奇数先手必败,否则必胜. 从3x3格子看,当n和m均为奇数时先手必败,…
BUPT2017 wintertraining(15) #5D HDU 1538 偷懒直接放个果壳的链接了,感觉比网上直接找这题的题解要更正确.易懂. 海盗博弈论 代码 #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; int t,n,m,p,a[10004],ans; int main() { for(int…
HDU.1847 Good Luck in CET-4 Everybody! ( 博弈论 SG分析) 题意分析 简单的SG分析 题意分析 简单的nim 博弈 博弈论快速入门 代码总览 //#include <cstdio> //using namespace std; // //int main() //{ // int n; // while(scanf("%d",&n) != EOF){ // if(n %3 == 0) printf("Cici\n&…
HDU.1850 Being a Good Boy in Spring Festival (博弈论 尼姆博弈) 题意分析 简单的nim 博弈 博弈论快速入门 代码总览 #include <bits/stdc++.h> #define nmax 105 using namespace std; int a[nmax]; int main() { int m; while(scanf("%d",&m) != EOF && m){ int ans = 0,…
HDU.2516 取石子游戏 (博弈论 斐波那契博弈) 题意分析 简单的斐波那契博弈 博弈论快速入门 代码总览 #include <bits/stdc++.h> #define nmax 51 using namespace std; int main() { int fib[nmax]; fib[1] = fib[2] = 1; for(int i = 3;i<nmax;++i){ fib[i] = fib[i-1] + fib[i-2]; } int n; while(scanf(&…
HDU.2147 kiki's game (博弈论 PN分析) 题意分析 简单的PN分析 博弈论快速入门 代码总览 #include <bits/stdc++.h> using namespace std; int main() { int n,m; while(scanf("%d %d",&n,&m) != EOF){ if(n == 0 && m == 0) break; if(n%2 && m%2){ printf(&q…
HDU.2149 Public Sale (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 #include <bits/stdc++.h> using namespace std; int main() { int n,m,s,r; while(scanf("%d %d",&m,&n) != EOF){ s = m%(n+1); if(s == 0) printf("none\n"); else{ r = (m -…
HDU.1846 Brave Game (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d",&t); while(t--){ int n,m; scanf("%d %d",&n,&m); int r,s; r = n%(m+1); if(r == 0) prin…
http://acm.hdu.edu.cn/showproblem.php?pid=4388 http://blog.csdn.net/y1196645376/article/details/52143551 好久没有写题了,再这么颓下去就要被彻底踩爆了(已经被彻底踩爆了). 这道题是一道博弈论,从侧面向我们揭示了一个客观规律,取东西的博弈论(不是定理的话)大多数都是从二进制入手(虽然这道题题目很显然是和二进制有关)进行一系列的找规律. 这道题的正解也同样给了我们一种看题的思路,从最基本的条件看…
Circles Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5299 Description There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent. Alice and…
悼念512汶川大地震遇难同胞--选拔志愿者 HDU 2188 博弈论 巴什博奕 题意 对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队,治疗和防疫的医护人员,以及进行心理疏导的心理学专家.根据要求,我校也有一个奔赴灾区救灾的名额,由于广大师生报名踊跃,学校不得不进行选拔来决定最后的人选.经过多轮的考核,形势逐渐明朗,最后的名额将在"林队"和"徐队"之间产生.但是很巧合,2个人的简历几乎一模一样,这让主…
取(2堆)石子游戏 HDU 2177 博弈论 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完者为胜者.现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者.如果你胜,你第1次怎样取子? 输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,…
取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完者为胜者.现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者. 输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000. 输出对…
题面传送门 题意: 有一棵 \(n\) 个节点的图 \(G\),R 和 B 两个人轮流操作,R 先操作. 每次操作 R 可以染红任意一条未染色的边,B 可以染蓝任意一条未染色的边 R 的目标是染成一棵全蓝的生成树,R 的目标是阻止后手染成一棵全蓝的生成树,问谁会赢. \(n \in [1,10]\),\(m \in [1,30]\) yet another 博弈论 problem...... 不难猜出本题的结论是如果 \(G\) 中存在两棵边集不相交的生成树,答案为 \(\texttt{YES}…
ZYB's Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5591 Description ZYB played a game named NumberBomb with his classmates in hiking:a host keeps a number in [1,N] in mind,then players guess a number in…