atcoder#TENKA12019D. Three Colors
Three Colors
Score : points
Problem Statement
You are given integers. The -th integer is . Find the number, modulo , of ways to paint each of the integers red, green or blue so that the following condition is satisfied:
- Let , and be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths , and .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of ways to paint each of the integers red, green or blue so that the condition is satisfied.
4
1
1
1
2
18
We can only paint the integers so that the lengths of the sides of the triangle will be , and , and there are such ways.
6
1
3
2
3
5
2
150
20
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
3
2
3
8
4
563038556