#H. G - Yet Another RGB Sequence

    传统题 1000ms 256MiB

G - Yet Another RGB Sequence

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

G - Yet Another RGB Sequence

Score : $600$ points

Problem Statement

You are given integers $R$, $G$, $B$, and $K$. How many strings $S$ consisting of R, G, and B satisfy all of the conditions below? Find the count modulo $998244353$.

  • The number of occurrences of R, G, and B in $S$ are $R$, $G$, and $B$, respectively.
  • The number of occurrences of RG as (contiguous) substrings in $S$ is $K$.

Constraints

  • $1 \leq R,G,B\leq 10^6$
  • $0 \leq K \leq \mathrm{min}(R,G)$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

RR GG BB KK

Output

Print the answer.


2 1 1 1
6

The following six strings satisfy the conditions.

  • RRGB
  • RGRB
  • RGBR
  • RBRG
  • BRRG
  • BRGR

1000000 1000000 1000000 1000000
80957240

Find the count modulo $998244353$.

2024暑假入门组刷题营第三期(四)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-7-11 13:00
结束于
2024-7-11 15:00
持续时间
2 小时
主持人
参赛人数
8