Codeforces869C The Intriguing Obsession
来源:互联网 发布:音乐播放器源码 编辑:程序博客网 时间:2024/06/07 20:01
标签:数学
— This is not playing but duty as allies ofjustice, Nii-chan!
— Not allies but justice itself, Onii-chan!
With hands joined, go everywhere at a speedfaster than our thoughts! This time, the Fire Sisters — Karen andTsukihi — 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 ofa, band c distinct islands respectively.
Bridges have been built between some(possibly all or none) of the islands. A bridge bidirectionally connects twodifferent 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 theshortest distance between them is at least 3, apparently in order to preventoddities 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 thenumber of different ways to build all bridges under the constraints, and givethe answer modulo 998 244 353. Two ways areconsidered different if a pair of islands exist, such that there's a bridgebetween them in one of them, but not in the other.
Input
The first and only line of input containsthree space-separated integersa, b and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in thered, blue and purple clusters, respectively.
Output
Output one line containing aninteger — the number of different ways to build bridges, modulo 998 244 353.
Examples
Input
1 1 1
Output
8
Input
1 2 2
Output
63
Input
1 3 5
Output
3264
Input
6 2 9
Output
813023575
Note
In the first example, there are 3 bridgesthat can possibly be built, and no setup of bridges violates the restrictions.Thus the answer is 23 = 8.
In the second example, the upper twostructures in the figure below are instances of valid ones, while the lower twoare invalid due to the blue and purple clusters, respectively.
分析:比赛的时候一直认为这题和杨辉三角有关(由于去年NOIP2016D2T1的坑)然后完美gg
正解应该是动规了吧(或者说是递推)
我们可以将a,b,c三个数分成(a,b,1),(a,c,1),(b,c,1)
将上述的三种情况相乘再取模就是最终的答案
而对于任意一种情况a,b
F(a,b)=f(a-1,b-1)*b+f(a-1,b)
Code
#include<bits/stdc++.h>#define rep(i,a,b) for(int i=a;i<=b;i++)#define dep(i,a,b) for(int i=a;i>=b;i--)#define LL unsigned long longusing namespace std;const int maxn=5006,mod=998244353;LL a,b,c,f[maxn][maxn],Max=0;int main(){ cin>>a>>b>>c; Max=max(a,max(b,c));rep(i,0,Max)f[i][0]=1,f[0][i]=1;rep(i,1,Max) rep(j,1,Max) f[i][j]=((f[i-1][j-1]*j)%mod+f[i-1][j])%mod;cout<<(((f[a][b]*f[b][c])%mod)*f[a][c])%mod<<endl;return 0;}
- Codeforces869C The Intriguing Obsession
- Codeforces869C-The Intriguing Obsession
- cf869C The Intriguing Obsession
- Codeforces Round439 C.The Intriguing Obsession
- [codefoces439C]The Intriguing Obsession(组合数学)
- Codefrces 869C. The Intriguing Obsession
- CodeForces 869C The Intriguing Obsession【排列组合】
- codeforces 869C The Intriguing Obsession 组合数学,逆元
- Codeforces Round #439 (Div. 2)-The Intriguing Obsession(DP)
- Codeforces Round #439 C. The Intriguing Obsession (组合数)
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces 869 C. The Intriguing Obsession (组合数学)
- Codeforces Round #439 C The Intriguing Obsession(dp)
- Codeforces Round #439 C.The Intriguing Obsession(DP + 思维)
- codeforces 869C. The Intriguing Obsession(组合数学)
- codeforces 869C The Intriguing Obsession 组合数学
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession dp
- Hibernate的持久化对象状态
- python里使用正则的finditer()函数
- mysql服务器无法连接10055错误解决示例
- FTPrep, 106 Construct Binary Tree from Inorder and Postorder Traversal
- JAVA提高篇(17)--打印流PrintStream记录日志文件
- Codeforces869C The Intriguing Obsession
- SecureCRT8.0安装与破解
- 彻底理解js的对象继承
- 《软件测试的艺术》读书心得 --- 软件测试的心理学和经济学
- 监控内存瓶颈
- 使用construct2制作简单游戏
- 有重复元素的排列问题
- FTPrep, 107 Binary Tree Level Order Traversal II
- 监控IO瓶颈