D - Yet Another ABC String Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 10001000

問題文

整数 A,B,CA,B,C が与えられます. A, B, C からなる文字列 SS であって,以下の条件をすべて満たすものの個数を 998244353998244353 で割った余りを求めてください.

  • SS に含まれる A, B, C の個数はそれぞれ A,B,CA,B,C 個である.
  • SS は(連続する)部分文字列として,ABC, BCA, CAB のいずれも含まない.

制約

  • 1A,B,C1061 \leq A,B,C \leq 10^6
  • 入力される値はすべて整数である

入力

入力は以下の形式で標準入力から与えられる.

AA BB CC

出力

答えを出力せよ.


入力例 1Copy

Copy
1 1 1

出力例 1Copy

Copy
3

条件を満たす文字列は,ACB, CBA, BAC33 つです.


入力例 2Copy

Copy
2 2 2

出力例 2Copy

Copy
42

入力例 3Copy

Copy
96 11 46

出力例 3Copy

Copy
818015722

入力例 4Copy

Copy
125132 102271 152064

出力例 4Copy

Copy
128086069

Score : 10001000 points

Problem Statement

You are given integers AA, BB, and CC. How many strings SS consisting of A, B, and C satisfy all of the following conditions? Find the count modulo 998244353998244353.

  • The number of occurrences of A, B, and C in SS are AA, BB, and CC, respectively.
  • SS contains none of ABC, BCA, and CAB as a (contiguous) substring.

Constraints

  • 1A,B,C1061 \leq A,B,C \leq 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

AA BB CC

Output

Print the answer.


Sample Input 1Copy

Copy
1 1 1

Sample Output 1Copy

Copy
3

The three strings that satisfy the conditions are ACB, CBA, and BAC.


Sample Input 2Copy

Copy
2 2 2

Sample Output 2Copy

Copy
42

Sample Input 3Copy

Copy
96 11 46

Sample Output 3Copy

Copy
818015722

Sample Input 4Copy

Copy
125132 102271 152064

Sample Output 4Copy

Copy
128086069


2025-04-28 (Mon)
11:17:50 +00:00