bzoj1430: 小猴打架
来源:互联网 发布:高频交易 程序员 编辑:程序博客网 时间:2024/04/26 07:37
链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1430
题意:中文题。。。
分析:prufer序列裸题。。编号为1~n的n个节点的树有n^(n-2)种,用prufer证。然后对于每一棵树的打架方案为(n-1)!。
代码:
#include<map>#include<set>#include<cmath>#include<queue>#include<math.h>#include<cstdio>#include<vector>#include<string>#include<cstring>#include<iostream>#include<algorithm>#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;const int N=10000010;const int MAX=151;const int MOD1=100000007;const int MOD2=100000009;const double EPS=0.00000001;typedef long long ll;const ll MOD=9999991;const ll INF=10000000010;typedef unsigned long long ull;int main(){ int i,n; ll ans; scanf("%d", &n); if (n==1) printf("0\n"); else { ans=1; for (i=1;i<=n-2;i++) ans=ans*n%MOD; for (i=1;i<n;i++) ans=ans*i%MOD; printf("%lld\n", (ans+MOD)%MOD); } return 0;}
0 0
- [BZOJ1430] 小猴打架
- bzoj1430: 小猴打架
- 【bzoj1430】小猴打架
- BZOJ1430 小猴打架
- [bzoj1430]小猴打架 水题
- [BZOJ1430]小猴打架(prufer序列+数学相关)
- prufer序列 图论?组合数学? BZOJ1430 小猴打架
- prufer编码 与 bzoj1430小猴打架 ——by lethalboy
- 1430: 小猴打架
- 1430: 小猴打架
- BZOJ P1430小猴打架
- BZOJ 1430 小猴打架
- 1430: 小猴打架 (prufer编码)
- bzoj 1430: 小猴打架 prefer编码
- BZOJ 1430: 小猴打架 prufer编码
- bzoj 1430: 小猴打架 (prufer序列+数论)
- BZOJ 1430: 小猴打架 树的prufer编码
- 打架
- 237. Delete Node in a Linked List
- 生活随笔:病人(4)
- CodeForces 158A Next Round
- 226. Invert Binary Tree
- 解决 Android Studio 构建项目 building project name gradle project info 卡死问题的几种方式
- bzoj1430: 小猴打架
- 283. Move Zeroes
- 100. Same Tree
- hdu 3367 Pseudoforest 最大权值和伪森林
- 242. Valid Anagram
- 算法导论例程——二叉搜索树
- 用Go开发WeChat接口的一个小坑
- MySQL 存储引擎
- POJ 2195 Going Home(费用流)