Codeforces 869C The Intriguing Obsession【组合数】
来源:互联网 发布:天锐绿盾软件怎么用 编辑:程序博客网 时间:2024/05/21 22:46
题目链接:http://codeforces.com/contest/869/problem/C
题意:3 个群岛,每个群岛分别有 a b c 个小岛,小岛之间可以连边,让两个相同颜色的点要么不连通,要么长度 > 3,问有多少种方案。
题解:组合题,我们发现一个岛只能连另一个群岛中的一个岛(否则不满足条件),我们可以推出,对于任意的
吐槽:我tm竟然连组合数的递推式都能背错,还调了好长时间…
代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <map> // STL#include <string> #include <vector>#include <queue>#include <stack>#define mpr make_pair#define debug() puts("okkkkkkkk")using namespace std;typedef long long LL;const int inf = 1 << 26, mod = 998244353;int a, b, c;int C[5005][5005], fac[5005];void init() { C[0][0] = 1; for ( int i = 1; i <= 5000; i ++ ) { C[i][0] = 1; for ( int j = 1; j <= i; j ++ ) { C[i][j] = (C[i-1][j-1]+C[i-1][j])%mod; } } fac[0] = fac[1] = 1; for ( int i = 1; i <= 5000; i ++ ) { fac[i] = (fac[i-1]*i)%mod; }}int calc(int x, int y) { int ans = 0, n = min(x, y); for ( int k = 0; k <= n; k ++ ) { ans += (C[x][k]%mod*C[y][k]%mod*fac[k]%mod)%mod; } return ans;}int main(){ scanf("%d %d %d", &a, &b, &c); init(); int ans = 1; ans = (int)((1LL*calc(a, b)%mod)*(1LL*calc(b, c)%mod)*(1LL*calc(a, c)%mod))%mod; printf("%d\n", ans); return 0;}
阅读全文
0 0
- Codeforces 869C The Intriguing Obsession【组合数】
- Codeforces-869C The Intriguing Obsession(DP/组合数)
- Codeforces Round #439 C. The Intriguing Obsession (组合数)
- Codeforces Round #439C 组合数-The Intriguing Obsession
- codeforces 869C The Intriguing Obsession 组合数学,逆元
- Codeforces 869 C. The Intriguing Obsession (组合数学)
- codeforces 869C. The Intriguing Obsession(组合数学)
- codeforces 869C The Intriguing Obsession 组合数学
- 【Codeforces 869 C The Intriguing Obsession】& 组合数学 & 思维
- CodeForces 869C The Intriguing Obsession【排列组合】
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession(组合数)
- Codeforces Round #439 (Div. 2)C. The Intriguing Obsession (组合数详解)
- Codeforces Round #439 (Div. 2) C.The Intriguing Obsession(组合数、记忆化搜索)
- Codeforces Round #439 C.The Intriguing Obsession(组合数学)
- CF869C:C. The Intriguing Obsession(组合数)
- Codeforces 869C ( Codeforces Round #439 (Div. 2) ) The Intriguing Obsession 组合数学
- Codeforces Round #439 (Div. 2) C 869C The Intriguing Obsession(思维+简单组合)
- [杂题 DP] Codeforces 869C. The Intriguing Obsession
- javascript基本包装类型介绍
- 最优二叉搜索树-------动态规划
- Git自学笔记
- JavaI/O中使用readUTF()报java.io.EOFException暂时解决方案
- Android开发艺术View基础
- Codeforces 869C The Intriguing Obsession【组合数】
- NOIP 2008提高组第三题
- JavaScript内存管理机制以及四种常见的内存泄漏解析
- 欢迎使用CSDN-markdown编辑器
- PG(HGDB)里创建表时不校验列名关键字
- 基于STM32原子战舰板内存管理源码详解
- string+STL——Password
- 初识Spring
- Sublime 32位 激活码