#abc266g. G - Yet Another RGB Sequence
G - Yet Another RGB Sequence
Score : points
问题描述
给定整数 ,, 和 。有多少个由 R
,G
和 B
组成的字符串 满足以下所有条件?请计算满足条件的字符串数量模 的结果。
- 字符串 中
R
、G
和B
出现的次数分别为 , 和 。 - 字符串 中作为(连续)子串出现的
RG
的次数为 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given integers , , , and . How many strings consisting of R
, G
, and B
satisfy all of the conditions below? Find the count modulo .
- The number of occurrences of
R
,G
, andB
in are , , and , respectively. - The number of occurrences of
RG
as (contiguous) substrings in is .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 1 1 1
Sample Output 1
6
The following six strings satisfy the conditions.
RRGB
RGRB
RGBR
RBRG
BRRG
BRGR
Sample Input 2
1000000 1000000 1000000 1000000
Sample Output 2
80957240
Find the count modulo .
update @ 2024/3/10 11:15:28