atcoder#AGC025B. [AGC025B] RGB Coloring
[AGC025B] RGB Coloring
Score : points
Problem Statement
Takahashi has a tower which is divided into layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:
- The beauty of the tower is the sum of the scores of the layers, where the score of a layer is if the layer is painted red, if the layer is painted green, if the layer is painted blue, and if the layer is uncolored.
Here, and are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.
Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly . How many such ways are there to paint the tower? Find the count modulo . Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
Constraints
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of the ways to paint tiles, modulo .
4 1 2 5
40
In this case, a red layer worth points, a green layer worth points and the blue layer worth points. The beauty of the tower is when we have one of the following sets of painted layers:
- green, blue
- red, blues
- reds, green
- reds, blue
The total number of the ways to produce them is .
2 5 6 0
1
The beauty of the tower is only when all the layers are uncolored. Thus, the answer is .
90081 33447 90629 6391049189
577742975