Yet Another ABC String

AtCoder
IDagc058_d
Time2000ms
Memory256MB
Difficulty
You are given integers $A$, $B$, and $C$. How many strings $S$ consisting of `A`, `B`, and `C` satisfy all of the following conditions? Find the count modulo $998244353$. * The number of occurrences of `A`, `B`, and `C` in $S$ are $A$, $B$, and $C$, respectively. * $S$ contains none of `ABC`, `BCA`, and `CAB` as a (contiguous) substring. ## Constraints * $1 \leq A,B,C \leq 10^6$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $A$ $B$ $C$ [samples]
Samples
Input #1
1 1 1
Output #1
3

The three strings that satisfy the conditions are `ACB`, `CBA`, and `BAC`.
Input #2
2 2 2
Output #2
42
Input #3
96 11 46
Output #3
818015722
Input #4
125132 102271 152064
Output #4
128086069
API Response (JSON)
{
  "problem": {
    "name": "Yet Another ABC String",
    "description": {
      "content": "You are given integers $A$, $B$, and $C$. How many strings $S$ consisting of `A`, `B`, and `C` satisfy all of the following conditions? Find the count modulo $998244353$. *   The number of occurrence",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc058_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given integers $A$, $B$, and $C$. How many strings $S$ consisting of `A`, `B`, and `C` satisfy all of the following conditions? Find the count modulo $998244353$.\n\n*   The number of occurrence...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments