摘要:
这题是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, 1, 2, and (1,2), with Sprague-Grundy values 0, 1, 2, 阅读全文
posted @ 2013-08-13 21:47
_随心所欲_
阅读(210)
评论(0)
推荐(0)
摘要:
详见:http://www.cnblogs.com/xin-hua/p/3255985.html约束条件6代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define in(x) scanf("%d",&x) 7 using namespace std; 8 int a[101]; 9 int main(){10 int n,i,j,t,ans,num,cnt,k;11 while(in(n)!=EOF){12 if(n==0){13 puts("Yes")... 阅读全文
posted @ 2013-08-13 20:52
_随心所欲_
阅读(266)
评论(0)
推荐(0)
摘要:
翻硬币游戏一般的翻硬币游戏的规则是这样的:N枚硬币排成一排,有的正面朝上,有的反面朝上。我们从左开始对硬币按1到N编号。第一,游戏者根据某些约束翻硬币,但他所翻动的硬币中,最右边那个硬币的必须是从正面翻到反面。例如,只能翻3个硬币的情况,那么第三个硬币必须是从正面翻到反面。如果局面是正正反,那就不能翻硬币了,因为第三个是反的。第二,谁不能翻谁输。有这样的结论:局面的SG值为局面中每个正面朝上的棋子单一存在时的SG值的异或和。即一个有k个硬币朝上,朝上硬币位置分布在的翻硬币游戏中,SG值是等于k个独立的开始时只有一个硬币朝上的翻硬币游戏的SG值异或和。比如THHTTH这个游戏中,2号、3号、6号 阅读全文
posted @ 2013-08-13 20:48
_随心所欲_
阅读(1113)
评论(1)
推荐(1)
摘要:
记忆化搜索+概率DP代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define ll __int64 9 #define pi acos(-1.0)10 #define MAX 5000011 using namespace std;12 int c[101],n,ff;13 double dp[100001];14 double solve(int f)15 {16 if(dp[f]>0) return dp[f];17 dp[f]=0;18 ... 阅读全文
posted @ 2013-08-13 11:15
_随心所欲_
阅读(243)
评论(0)
推荐(0)
摘要:
题意:1-n个位置中,每个位置填一个数,问至少有l个数是相同的概率。可以转化求最多有l-1个数是相同的。dp[i][j]表示前i个位置填充j个位置的方案数,并且要满足上面的条件。则:dp[i][j]=∑dp[i-1][j-k]*c[m-j+k][k];也就是看第i个数,可以不填,填一个位置,两个位置······这样累加过来。代码如下: 1 import java.math.*; 2 import java.util.*; 3 public class Main { 4 public static void main(String ar 阅读全文
posted @ 2013-08-13 10:49
_随心所欲_
阅读(178)
评论(0)
推荐(0)