atcoder#AGC058D. [AGC058D] Yet Another ABC String
[AGC058D] Yet Another ABC String
Score : points
Problem Statement
You are given integers , , and .
How many strings consisting of A
, B
, and C
satisfy all of the following conditions? Find the count modulo .
- The number of occurrences of
A
,B
, andC
in are , , and , respectively. - contains none of
ABC
,BCA
, andCAB
as a (contiguous) substring.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
1 1 1
3
The three strings that satisfy the conditions are ACB
, CBA
, and BAC
.
2 2 2
42
96 11 46
818015722
125132 102271 152064
128086069