Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学

来源:互联网 发布:王珊 数据库三版答案 编辑:程序博客网 时间:2024/05/23 19:22

C. The Intriguing Obsession
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

— 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 ab 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.

Input

The first and only line of input contains three space-separated integers ab and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in the red, blue and purple clusters, respectively.

Output

Output one line containing an integer — 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 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("");}


阅读全文
0 0
原创粉丝点击