![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDU
become__better
大胆去问,大胆去做,效率
展开
-
HDU 1166 敌兵布阵(树状数组)
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1166树状数组基础题include<stdio.h>#include <iostream>#include <stdio.h>#include <cmath>using namespace std;int a[50045],node[50045...原创 2019-03-08 21:23:09 · 91 阅读 · 0 评论 -
取石子游戏 HDU - 2516(斐波那契博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2516斐波那契博弈模版题。当n为斐波那契数列时,后手必胜,其他时,先手必胜。想深入了解,可以看这篇博客:https://blog.csdn.net/dgq8211/article/details/7602807#include<iostream>#include<algorit...原创 2019-07-27 20:03:53 · 193 阅读 · 0 评论 -
Game HDU - 3389(尼姆博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3389#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int a[10009];int main(){ ...原创 2019-07-27 21:12:46 · 129 阅读 · 0 评论 -
Calendar Game HDU - 1079(博弈 NP状态定理)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079非常经典的 NP状态博弈,有三种方法,记忆化搜索,逆序递推,找规律。NP状态定理:P是“胜利终止状态”或者它的一切后继状态都是N状态,N是“失败终止状态”或者至少拥有一个后继状态是P状态。也就是说后继状态为P的一定为N状态,不存在后继状态为N的为P状态。进行记忆化搜索将年份-1900...原创 2019-07-27 18:01:15 · 288 阅读 · 0 评论 -
Euclid's Game HDU - 1525 (博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1525题意:给你两个数a,b。要求用较大的数减去较小的数的任意倍数,两方轮流操作,出现0的一方获胜。思路:设较大者为n,较小者为m。当n%m==0时,此时操作者必胜。当n>m但<2m时,只能让n=n-m,没有选择的空间;当n>=2m时,此时操作者也必胜。因为将(n%m与n>=...原创 2019-07-27 19:19:07 · 127 阅读 · 0 评论 -
No Gambling HDU - 3863(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3863思路:先手必胜。感觉是先手必胜,但又不好证明。搏一搏,摩托变飞机。一交就AC了。#include <cstdio>#include <iostream>#include <cstring>#include <string>#includ...原创 2019-07-28 09:02:04 · 167 阅读 · 0 评论 -
Coin Game HDU - 3951(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3951题意:两个玩家用一圈N硬币开始游戏。他们轮流从圆圈里取硬币,每次可以取1~k个连续的硬币。(假设10个硬币从1到10,k等于3,因为1和10是连续的,你可以拿走连续的10、1、2,但是如果2被拿走,你不能拿走1、3、4,因为1和3不是连续的)。拿最后一枚硬币的玩家获胜。思路:当一次能取完时,...原创 2019-07-28 09:25:30 · 609 阅读 · 0 评论 -
Public Sale HDU - 2149(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2149思路:**巴什博弈。**把N元看成n个石子。当n%(m+1)==0时后手必胜,其他时先手必胜。在先手能一次取完时,输出n n+1 …m。其他时,先手取完后,让n%(m+1)==0,那么取得个数就是n%(m+1)#include <cstdio>#include <ios...原创 2019-07-28 10:04:09 · 178 阅读 · 0 评论 -
取(m堆)石子游戏 HDU - 2176(尼姆博奕)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2176#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<stdlib.h>#include<queue>#includ...原创 2019-07-28 10:49:18 · 141 阅读 · 0 评论 -
取(2堆)石子游戏 HDU - 2177(威佐夫博奕)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2177在先手必胜时,有两种情况W>X和W<XW<XW>X#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main()...原创 2019-07-28 11:02:01 · 191 阅读 · 0 评论 -
Dice HDU - 4652(期望)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4652题意:有一个m面的骰子,分别求出现最后n次点数相同与最后n次点数各不同的期望次数。思路:期望DPf[i]=∑p[i - j] * (f[j]+w[i-j])p[i-j]表示状态i到状态j的概率,f[i]表示状态i到达终点状态的期望,w[i-j]表示状态i转移到状态j所贡献的期望值最后...原创 2019-08-05 21:04:43 · 152 阅读 · 0 评论 -
Brave Game HDU - 1846(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846巴什博弈的模版题,当n%(m+1)==0时,后手胜;其他时,先手胜。#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int...原创 2019-07-27 19:45:56 · 93 阅读 · 0 评论 -
Play a game HDU - 1564(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1564题意:有一个n*n的棋盘,棋子开始在四个边角中的任意一个,棋子可以水平或垂直移动到未访问的格子中,不能移动者失败。当n为奇数时,后手必胜,n为偶数是先手必胜。看棋盘除了起点外,能不能分成任意个2 *1的格子。比如当n=4时与n=3时。#include<iostream>#...原创 2019-07-27 19:42:40 · 152 阅读 · 0 评论 -
HDU 2689 Sort it(树状数组)白书P178
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2689include <iostream>#include <string.h>#include <stdio.h>using namespace std;int bit[1010],n;int sum(int i){ int s=0; ...原创 2019-03-09 20:25:27 · 110 阅读 · 0 评论 -
HDU1556Color the ball(树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556#include <iostream>#include <cstring>#include <stdint.h>#include <stdio.h>using namespace std;int bit[100010],n;int su...原创 2019-03-09 21:38:14 · 95 阅读 · 0 评论 -
HDU 1847 Good Luck in CET-4 Everybody! ( 博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1847#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>using namespace st...原创 2019-03-27 20:21:13 · 85 阅读 · 0 评论 -
HDU 4082 Hou Yi's secret(相似三角形最大数量)(模拟加精度)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4082给你若干个点,求相似三角形最大数量。点最多只有18个,可以尽情暴力。WA点在于:点有重复,需要判重。** 开方(sqrt)损失了精度。**敲黑板 谨记谨记:以后计算几何的题尽量少开方!!!#include<iostream>#include<cstdio>...原创 2019-05-03 17:02:56 · 110 阅读 · 0 评论 -
矩形面积 HDU - 5251 (旋转卡壳 求最小矩形覆盖)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5251开始没想到用凸包,看了大佬的博客才明白。思路:矩形各边必经过凸包上的点,并且矩形一边为凸包上的边,另外三边经过凸包上的点。先枚举矩形的一个边(即凸包上的边),再确定另外三点。矩形为高低左右四边,假设此边为为低边(相对意义上的),再确定另外三边上的三个点即可。与此边距离最大的点是高边上的点,利用...原创 2019-07-03 21:24:34 · 265 阅读 · 0 评论 -
A Multiplication Game HDU - 1517(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1517题意:一个数p初始为1,每个人可以把P乘以2~~9,当操作完P>=n时,操作者获胜。思路:当n在9m2m+1–9m+12m先手必胜,当n在9m+12m+1–9m+12m+1后手必胜2-9时先手必胜,910-18时后手必胜。2* 919-162时先手必胜,9* 2* 9163-32...原创 2019-07-30 10:28:40 · 111 阅读 · 0 评论 -
A simple stone game HDU - 2486(博弈,k倍动态减法)
思路:博弈论中的 K倍动态减法游戏,难度较大,参看了好多资料才懵懂!此题可以看作 Fibonacci 博弈的扩展,建议没弄懂 Fibonacci博弈的先学那个,个人整理 http://blog.csdn.net/tbl_123/article/details/24033245 ;而说扩展体现在数列不再是Fib数列,是根据 k 的值自行构造的,其它换汤不换药,具体构造方法如下:这儿方便说明白...转载 2019-07-30 10:46:49 · 264 阅读 · 0 评论 -
Fibonacci again and again HDU 1848(博弈 SG函数)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1848#include<iostream>#include<algorithm>#include<string>#include<sstream>#include<set>#include<vector>#includ...原创 2019-07-21 20:55:03 · 92 阅读 · 0 评论 -
邂逅明下 HDU - 2897(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2897题意:一堆有n个石子,一次最少取p个,最多取q个,小于p个则一次性取完,取完者输。思路:我们可以转化成巴什博弈,变成取完者赢,设m=p+q。那么在不取最后一块的前提下,如果他取了倒数第二块,那么下一个必败,此时(n-1)%m=0,后手必胜,即n%m=1。只要他留给对手的块数小于p,那么他必胜,...原创 2019-07-22 15:20:14 · 164 阅读 · 0 评论 -
Nim or not Nim? HDU - 3032(SG函数 找规律)
打表代码:#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;#define maxn 156int s[maxn],sg[maxn];void init(){ memset(sg,0,sizeof...原创 2019-07-22 19:15:28 · 137 阅读 · 0 评论 -
Walk HDU - 5001 (概率)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5001#include <algorithm>#include <iostream>#include <stdlib.h>#include <string.h>#include <iomanip>#include <stdio...原创 2019-08-10 11:20:14 · 103 阅读 · 0 评论