SG函数
ZJLORD
这个作者很懒,什么都没留下…
展开
-
Hdu1404 Digital Deletions
题意: 给定一串序列,每次可以删除0右边的数或者把最右边的数改为比他小的数。 开始不会,搜的题解,完全没想到SG函数,哎! 由于题目给定的序列不长,最多就是只有1e6,可以直接暴力打个1~1e6的SG函数值。然后最后只需要根据当前的SGh函数值判断就行。关于这个怎么打SG 函数的表我其实也不太会,反正别人的代码写的挺好,我肯定想不到了。 #include #include u原创 2017-08-10 19:37:14 · 274 阅读 · 0 评论 -
POJ 2960 S-Nim (sg函数)
S_Nim 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原创 2017-08-10 19:57:40 · 182 阅读 · 0 评论 -
hdu 1729 Stone Game
HDU Stone Game 大概是一道水题吧,了解SG函数的性质就行。 不过还是看了别人的代码。 具体分析 点击打开 找到必胜的条件吧,然后可以递归来求解不确定状态吧。 #include #include #include #include using namespace std; int SG(int s,int t) { int c=sqrt(s原创 2017-08-10 20:09:54 · 228 阅读 · 0 评论 -
hdu---(1848)Fibonacci again and again
分析发现就是一个SG 函数的变形, 具体来说就是打个Fibonacci 函数的表,然后再打个SG 函数的表就完美的解决了。 #include #include #include #include #include #define N 5050 int f[N],sg[N],hash[N]; void getSG(int n) { int i,j; memset(sg,原创 2017-08-10 20:35:36 · 179 阅读 · 0 评论 -
Bomb Game
SG函数,第一个二维平面算SG函数的题: 对于在边界上的点之后向一边扩展,而对于中间的无边界的点就会向两边扩张,即 SG[a][j]^SG[i][b] ; #include #include using namespace std; const int maxn =52; int hash[10010]; int map[maxn][maxn]; int Get_原创 2017-08-10 20:49:16 · 942 阅读 · 0 评论 -
Nim or not Nim? HDU 3032
SG函数+1; 由于题目给的数据很大,直接写SG 肯定会超时,这时候就只能打表找规律了。 打出SG函数的表,然后找出规律。 实在看不出就往下滑吧。 打表SG: #include #include int sg[1007],vis[1007]; int main() { sg[0]=0;sg[1]=1; int j; for(int i=2;i<=1原创 2017-08-10 20:52:05 · 207 阅读 · 0 评论