【hdu 3032】Nim or not Nim?】的更多相关文章

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2016 Accepted Submission(s): 1048 Problem Description Nim is a two-player mathematic game of strategy in which players take turns removing objects f…
[HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int a[20]; __int64 dp[20][11]; void digit_dp() { memset(dp, 0LL, sizeof(dp)); dp[0][0]=1; for(int i=1; i<20; ++i)…
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 332    Accepted Submission(s): 112 Problem Description DZY has an unroote…
[把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最高位的1在第x位. [就是原集合的任意子集的异或和 与 线性基的任意子集的异或和 完全相等] 2.线性基的构造法: 对每个数p从高位到低位扫,扫到第x位为1时,若ax不存在,则ax=p并结束此数的扫描,否则令p=p xor ax. [高斯消元] 异或版高斯消元后的线性基会变成类似上面的样子(线性基是…
[HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解,先求出树的直径,那么树的任意节点的最远点必然是直径上的两个端点之一,证明可以通过反证法构造: 设端点为a,b;设任意点为i,假设存在一点c到i的距离大鱼i到a,b的距离,那么a与c又能形成一个距离更长的点对,与ab是直径的假设不符,因此不存在c,证明完成. #include <queue> #i…
[HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题:给出一棵树,求每个节点的最远点,每一个节点的最远点有两种可能,一种是向下拓展的最远点,一种是父节点的最远点,那么需要两次dfs即可.一次求出每个节点的最远点和次远点,一次直接计算. #include <queue> #include <cmath> #include <cstd…
pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 593    Accepted Submission(s): 179 Problem Description NPY's girlfriend blew him out!H…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=2176 [算法] Nim博弈 当石子数异或和不为0时,先手必胜,否则先手必败 设石子异或和为S 如果S xor ai <= ai,那么,第一步就可以从第i堆石子中取走(S xor ai)个石子 [代码] #include<bits/stdc++.h> using namespace std; #define MAXM 200010 int i,m,k,sum; int a[MAXM]; i…
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1286 Accepted Submission(s): 585 Problem Description Alice and Bob are playing a game called "Climbing the Hill". The game board consists of ce…
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 208 Accepted Submission(s): 119 Problem Description dingyeye loves play stone game with you. dingyeye has an n-point tree.The nodes are numbered fro…