Codeforces869c the intriguing obsession

Posted by yjjr's blog on February 6, 2018

标签:数学

— 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 long
using 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;
}



本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr