上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 30 下一页
摘要: 这题是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)
摘要: 思路:两个数a和b,总会出现的一个局面是b,a%b,这是必然的,如果a>=b&&a=2的话,先手可以选择由谁面对b,a%b这样的局势,先手在a/b>=2的局面必胜代码如下: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main(){ 7 int a,b,t; 8 while(scanf("%d%d",&a,&b)!=EOF&&(a+b)){ 9 if(a=2) break;13 t=a;14 a=b;15 ... 阅读全文
posted @ 2013-08-12 22:11 _随心所欲_ 阅读(153) 评论(0) 推荐(0)
摘要: 方法一:找规律,很容易知道1 #include2 int main(){3 int n;4 while(scanf("%d",&n)!=EOF){5 puts(n%3==0?"Cici":"Kiki");6 }7 return 0;8 }View Code 方法二:简单的sg函数应用代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define ll __int64 9 #define pi acos(-1 阅读全文
posted @ 2013-08-12 21:48 _随心所欲_ 阅读(187) 评论(0) 推荐(0)
摘要: 看到这题时,当时还不会做,也没搞懂sg函数,于是狠狠的钻研了下博弈论,渐渐的知道了sg函数……现在在来做这题就很容易了,1A打表容易发现在80左右的时候就出现循环节了代码如下: 1 #include 2 #include 3 #define in(x) scanf("%d",&x) 4 int sg[101]; 5 bool vis[101]; 6 int getsg(int x) 7 { 8 if(sg[x]>=0) return sg[x]; 9 memset(vis,0,sizeof(vis));10 for(int i=0;i=100){19 i... 阅读全文
posted @ 2013-08-12 19:07 _随心所欲_ 阅读(391) 评论(0) 推荐(0)
摘要: 很容易想到三分法求解,不过要分别在0-pi,pi-2pi进行三分。另外也可以直接暴力枚举……代码如下: 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 50000 11 using namespace std; 12 struct point 13 { 14 double x,y; 15 point(double _x=0,double ... 阅读全文
posted @ 2013-08-12 16:49 _随心所欲_ 阅读(408) 评论(0) 推荐(0)
摘要: 思路:dp[i][j][k]表示在点(i,j)处能量的差值为k的方案数转移的时候把差值取相反数就实现轮流了代码如下: 1 #include 2 #include 3 #include 4 #define MAX 480 5 #define mod 1000000007 6 using namespace std; 7 int dp[MAX][MAX][11]; 8 char str[MAX][MAX]; 9 int main(){10 int t,i,j,k,c=0,n,m,t1,t2,ans;11 scanf("%d",&t);12 while(t--){13 . 阅读全文
posted @ 2013-08-12 11:17 _随心所欲_ 阅读(188) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 30 下一页