天天看點

Codeforces 869C ( Codeforces Round #439 (Div. 2) ) The Intriguing Obsession 組合數學

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 a, band 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 a, b 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 is 23 = 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.

Codeforces 869C ( Codeforces Round #439 (Div. 2) ) The Intriguing Obsession 組合數學

有三類不同的點。現在給出每種點的個數,要求連邊組成無向圖,統計使得任意兩個相同顔色的點之間距離至少為3或者不連通的連邊方案數。

對于任意兩堆之間,連邊的方案數是獨立的。是以,我們隻要單獨考慮12,13,23每對點堆分别連邊的方案數,再乘起來。

對于每兩堆,假設各有a,b個點。(a>b)

兩堆間連一條邊,顯然有C(b,1)*a種。

連第二條邊,有C(b,2)*a*(a-1)種。

.......

連第b條邊,有C(b,b)*a*(a-1)*...*(a-b+1)種。

最後加起來就是總數。

#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=5005,inf=0x3f3f3f3f;  
const ll llinf=0x3f3f3f3f3f3f3f3f,mod=998244353;   
const ld pi=acos(-1.0L);
ll C[maxn][maxn];

int main() {
	ll a,b,c,i,j;
	cin >> a >> b >> c;
	C[0][0]=1;
	for (i=1;i<=5000;i++) {
		C[i][0]=1;
		for (j=1;j<=i;j++) {
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			C[i][j]%=mod;
		}
	}
	if (a<b) swap(a,b);
	if (a<c) swap(a,c);
	if (b<c) swap(b,c);
	ll na,nb,nc,l;
	l=1;
	na=nb=nc=1;
	for (i=a;i>=a-b+1;i--) {
		l*=i;
		l%=mod;
		na+=l*C[b][a-i+1];na%=mod;
//		cout << na << endl;
	}
	l=1; 
	for (i=a;i>=a-c+1;i--) {
		l*=i;
		l%=mod;
		nb+=l*C[c][a-i+1];nb%=mod;
	}
	l=1;
	for (i=b;i>=b-c+1;i--) {
		l*=i;
		l%=mod;
		nc+=l*C[c][b-i+1];nc%=mod;
	}
	ll ans=(((na*nb)%mod)*nc)%mod;
	printf("%I64d\n",ans);
	return 0;
}