Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学
来源:互联网 发布:王珊 数据库三版答案 编辑:程序博客网 时间:2024/05/23 19:22
— This is not playing but duty as allies of justice, Nii-chan!
— Not allies but justice itself, Onii-chan!
With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they've never reached — water-surrounded islands!
There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, b and c distinct islands respectively.
Bridges have been built between some (possibly all or none) of the islands. A bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they shouldn't be reached from each other through bridges, or the shortest distance between them is at least 3, apparently in order to prevent oddities from spreading quickly inside a cluster.
The Fire Sisters are ready for the unknown, but they'd also like to test your courage. And you're here to figure out the number of different ways to build all bridges under the constraints, and give the answer modulo 998 244 353. Two ways are considered different if a pair of islands exist, such that there's a bridge between them in one of them, but not in the other.
The first and only line of input contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in the red, blue and purple clusters, respectively.
Output one line containing an integer — the number of different ways to build bridges, modulo 998 244 353.
1 1 1
8
1 2 2
63
1 3 5
3264
6 2 9
813023575
In the first example, there are 3 bridges that can possibly be built, and no setup of bridges violates the restrictions. Thus the answer is23 = 8.
In the second example, the upper two structures in the figure below are instances of valid ones, while the lower two are invalid due to the blue and purple clusters, respectively.
就是两个同色点之间不能相恋,或只有一个点在他们中间
所以说,最后只要把x->y y->z z->x的方案乘起来就好了
一对颜色了连接方案就是酱
#include<cmath>#include<ctime>#include<cstdio>#include<cstring>#include<cstdlib>#include<complex>#include<iostream>#include<algorithm>#include<iomanip>#include<vector>#include<bitset>#include<string>#include<queue>#include<set>#include<map>using namespace std;typedef long long ll;inline int read(){int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch<='9'&&ch>='0'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}void print(ll x){if(x<0)putchar('-'),x=-x;if(x>=10)print(x/10);putchar(x%10+'0');}const ll mod=998244353;const int N=5110;ll f[N][N];int main(){register int i,j;for(i=1;i<N;i++)f[1][i]=i+1;for(i=2;i<N;i++)for(j=1;j<N;j++)if(j<i)f[i][j]=f[j][i];else {(f[i][j]+=j*f[i-1][j-1]%mod)%=mod;(f[i][j]+=f[i-1][j])%=mod;}register int a,b,c;a=read();b=read();c=read();ll ans=f[a][b]*f[b][c]%mod*f[c][a]%mod;print(ans);puts("");}
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学
- Codeforces 869C ( Codeforces Round #439 (Div. 2) ) 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 dp
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession(dp)
- Codeforces Round #439 (Div. 2) 869 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(组合数学)
- Codeforces Round #439 (Div. 2)-The Intriguing Obsession(DP)
- #439 Div.2 C. The Intriguing Obsession 组合数学
- CF round#439 div.2 C The Intriguing Obsession【DP】
- Codeforces Round #439 (Div. 2) C 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(组合数、记忆化搜索)
- 用construct2制作童年经典的弹珠游戏粗略说明
- 二级缓存的实现
- 自定义圆加减速
- csrf 原理与解决方案
- 对角线之和
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学
- 在hibernate中使用c3p0数据源。
- VS2013快捷键
- 依赖
- Java程序猿不容错过的开发趋势
- 调查报告:Python成最热门工具!近半程序员认为上级技术水平不如自己!
- 论精简代码和臃肿代码的区别
- SpringBoot学习笔记
- MVP项目框架搭建-高级设计