2013年6月28日
摘要: 计数方法包括加法原理和乘法原理。乘法原理是加法原理的特殊情况,加法原理在分类有重复的情况下,可以使用容斥原理。加法原理:做一件事有n个方法,第i个方法有pi种方案,则一共有p1+p2+……+pn种方案。乘法原理:做一件事有n个方法,第i个步骤有pi种方案,则一共有p1p2……pn种方案。几个常见的计数问题。组合排列:性质一:C(n ,0)=C(n ,n)=1性质二:C(n ,k)=C(n ,n-k)性质三:C(n , k)+C(n ,k+1) =C (n+1,k+1)性质四:C(n ,k+1)=C(n ,k)*(n-k)/(k+1)有重复元素的全排列:n1!n2!……nk!x=n!可重复选择的 阅读全文
posted @ 2013-06-28 21:35 Ac_国士无双 阅读(408) 评论(0) 推荐(0) 编辑
  2013年6月11日
摘要: 题意要求除了对输赢的判断,还有对第一次取法的计数。所以先要对状态做判断,至于取法则是要看每堆扑克牌与异或结果最高位对应的位上是否为1. 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <cstdlib> 6 #include <climits> 7 #include <sstream> 8 #include <fstream> 9 #include &l 阅读全文
posted @ 2013-06-11 20:44 Ac_国士无双 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题不难,看题意的时候把自己坑了,还以为是威佐夫博奕,其实直接求SG值,规律很好找。 1 #include<stdio.h> 2 int main() 3 { 4 int n,m; 5 while(scanf("%d%d",&n,&m)!=EOF) 6 { 7 if(n==0&&m==0) 8 break; 9 if(m&1&&n&1)10 printf("What a pity!\n");11 else12 printf("Wonderful!\n");1.. 阅读全文
posted @ 2013-06-11 18:29 Ac_国士无双 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 巴什博奕,简单题 1 #include<stdio.h> 2 int main() 3 { 4 int m,n,s,i; 5 while(scanf("%d%d",&m,&n)!=EOF) 6 { 7 if(n>=m) 8 { 9 for(i=m;i<n;i++)10 printf("%d ",i);11 printf("%d\n",i);12 continue;13 }14 s=m%(n+1);15 ... 阅读全文
posted @ 2013-06-11 18:26 Ac_国士无双 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 求两段区间中最大公约数为k的数字的对数,下界除以k后就会变成,求区间中与n互质的数字的对数。主要错在了两个地方,k=0和b,d大小的判断。 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <cstdlib> 6 #include <climits> 7 #include <sstream> 8 #include <fstream> 9 #include 阅读全文
posted @ 2013-06-11 14:38 Ac_国士无双 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 容斥原理,求会被去掉的数字的个数,在ai组成的集合中用最小公倍数作为除数。 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <cstdlib> 6 #include <climits> 7 #include <sstream> 8 #include <fstream> 9 #include <cstdio>10 #include <st 阅读全文
posted @ 2013-06-11 14:28 Ac_国士无双 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 区间找素数,求差。(if( len <=1) 这里把<漏了,Runtime error,原因:ans是空的。 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <cstdlib> 6 #include <climits> 7 #include <sstream> 8 #include <fstream> 9 #include <cstdi 阅读全文
posted @ 2013-06-11 09:32 Ac_国士无双 阅读(181) 评论(0) 推荐(0) 编辑
  2013年6月10日
摘要: 求能使a,b同余的正整数m的个数,即a,b差的因子个数。 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <cstdlib> 6 #include <climits> 7 #include <sstream> 8 #include <fstream> 9 #include <cstdio>10 #include <string>1 阅读全文
posted @ 2013-06-10 18:01 Ac_国士无双 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 博弈,求SG值 1 #include<stdio.h> 2 int main() 3 { 4 int n; 5 while(scanf("%d",&n)!=EOF) 6 { 7 if(n%3==0) 8 printf("Cici\n"); 9 else10 printf("Kiki\n");11 }12 return 0;13 } 阅读全文
posted @ 2013-06-10 17:04 Ac_国士无双 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 博弈,水题#include<stdio.h>int main(){ int c,n,m; scanf("%d",&c); while(c--) { scanf("%d%d",&n,&m); if(n%(m+1)==0) printf("second\n"); else printf("first\n"); } return 0;} 阅读全文
posted @ 2013-06-10 16:47 Ac_国士无双 阅读(92) 评论(0) 推荐(0) 编辑