#P15566. [COCI 2025/2026 #5] 重量 / Težina
[COCI 2025/2026 #5] 重量 / Težina
Background
The full score for this problem is .
Problem Description
In front of the strongman Karlo at the gym, there is an array of length , where represents the weight of the -th item. He can also use different “weight types”, numbered .
For each weight type from to , Karlo considers every item in the array in order and follows the process below:
- Compute the result of dividing the item’s weight by the current weight type (discard the fractional part), and record this integer.
- Multiply this integer by “the item’s weight ”. If the resulting integer is greater than , replace it with .
- Add up the integers obtained for all items to get the “strength value” of this weight type.
Karlo wants to know the sum of the strength values of all weight types. Please help him solve this problem.
Input Format
The first line contains two natural numbers (), representing the number of items and the number of weight types.
The second line contains integers ().
Output Format
Output one integer on a single line, representing the required total sum.
1 2
2
12
2 1
3 4
39
7 19
1 2 3 4 5 6 7
414
Hint
Sample Explanation
Explanation for Sample #2:
In this sample, there is only weight type :
The total sum is .
Subtasks
| Subtask | Score | Constraints |
|---|---|---|
| The number of distinct values in array is at most | ||
| No additional constraints |
Translated by ChatGPT 5