摘要: 题解:n为树的节点数,d[ ]为各节点的度数,m为无限制度数的节点数。则所以要求在n-2大小的数组中插入tot各序号,共有种插法;在tot各序号排列中,插第一个节点的方法有种插法;插第二个节点的方法有种插法; .........另外还有m各节点无度数限制,所以它们可任意排列在剩余的n-2-tot的空... 阅读全文
posted @ 2014-07-17 15:10 forever97 阅读(571) 评论(0) 推荐(0) 编辑
摘要: 题解:数据结构的基本操作,用STL可以完美实现,就是比较慢……#include #include #include #include #include const int MAXN=500005; const int INF=~0U>>1; using namespace std; ... 阅读全文
posted @ 2014-07-17 14:42 forever97 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题解:正难则反,从总数中减去全部相邻不相同的数目就是答案,n*(n-1)^(m-1):第一个房间有n中染色方案,剩下m-1个房间均只有n-1种染色方案,用总数减就是答案。#include const int mod=100003; typedef long long LL; LL n,m; LL p... 阅读全文
posted @ 2014-07-17 10:44 forever97 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 题解:简单的NIM游戏,直接计算SG函数,至于找先手策略则按字典序异或掉,去除石子后再异或判断,若可行则直接输出。#include const int N=1005;int SG[N],b[N],hash[N],a[N],sum,tmp,i,j,n,m; void FSG(int s){ ... 阅读全文
posted @ 2014-07-17 09:57 forever97 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题解:注意题目中规定取到最后一粒石子的人算输,所以是Anti-Nim游戏,胜负判断为:先手必胜: 1.所有堆的石子数都为1且游戏的SG值为0; 2.有些堆的石子数大于1且游戏的SG值不为0。#include int main(){ int t,n,s,x,tmp; scanf("%d... 阅读全文
posted @ 2014-07-17 09:23 forever97 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 题解:直接使用STL中的hash去重即可#include #include using namespace std;int ans[50010];int main(){ int T,n,tmp; scanf("%d",&T); while(T--){ int cnt=... 阅读全文
posted @ 2014-07-17 08:45 forever97 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 题解:简单博弈论#include int main(){ int n; while(scanf("%d",&n),n!=0) if (n&1) puts("Bob"); else puts("Alice"); return 0;} 阅读全文
posted @ 2014-07-17 08:42 forever97 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 题解:鉴于二进制的思想来划分#include int main(){ int n,d=0;scanf("%d",&n); while(1<<d<=n)d++; printf("%d\n",d);} 阅读全文
posted @ 2014-07-17 08:38 forever97 阅读(176) 评论(0) 推荐(0) 编辑