atcoder#ABC266G. [ABC266G] Yet Another RGB Sequence
[ABC266G] Yet Another RGB Sequence
Score : points
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.
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 .