atcoder#ABC251B. [ABC251B] At Most 3 (Judge ver.)
[ABC251B] At Most 3 (Judge ver.)
Score : points
Problem Statement
There are weights called Weight , Weight , , Weight . Weight has a mass of . Let us say a positive integer is a good integer if the following condition is satisfied:
- We can choose at most 3 different weights so that they have a total mass of .
How many positive integers less than or equal to are good integers?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 10
1 3
3
If we choose only Weight , it has a total mass of , so is a good integer. If we choose only Weight , it has a total mass of , so is a good integer. If we choose Weights and , they have a total mass of , so is a good integer. No other integer is a good integer. Also, all of , , and are integers less than or equal to . Therefore, the answer is .
2 1
2 3
0
There are no good integers less than or equal to .
4 12
3 3 3 3
3
There are good integers: , and . For example, if we choose Weights , , and , they have a total mass of , so is a good integer. Note that is not a good integer.
7 251
202 20 5 1 4 2 100
48