#abc251b. B - At Most 3 (Judge ver.)
B - At Most 3 (Judge ver.)
Score : points
问题描述
设有 个重量,分别称为 Weight 、Weight 、、Weight 。其中,Weight 的质量为 。
我们称一个正整数 为 好整数 ,如果满足以下条件:
- 我们可以选择 最多3个 不同的重量,使得它们的总质量恰好为 。
请问不大于 的好整数有多少个?
以上为通义千问 qwen-max 翻译,仅供参考。
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 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.
Sample Input 1
2 10
1 3
Sample Output 1
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 .
Sample Input 2
2 1
2 3
Sample Output 2
0
There are no good integers less than or equal to .
Sample Input 3
4 12
3 3 3 3
Sample Output 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.
Sample Input 4
7 251
202 20 5 1 4 2 100
Sample Output 4
48
update @ 2024/3/10 10:42:30