#P8663. [蓝桥杯 2018 省 A] 倍数问题
[蓝桥杯 2018 省 A] 倍数问题
Problem Description
As everyone knows, student Xiaocong is good at calculations, especially at checking whether one number is a multiple of another. However, Xiaocong is only good at the case with two numbers, and becomes troubled when there are many numbers. Now Xiaocong gives you numbers and hopes that you can find three numbers among them such that the sum of these three numbers is a multiple of , and this sum is as large as possible. The testdata guarantees that a solution always exists.
Input Format
Read input from standard input.
The first line contains positive integers, and .
The second line contains positive integers, representing the given numbers.
Output Format
Output one line containing one integer, the required sum.
4 3
1 2 3 4
9
Hint
Sample Explanation
Choose , , and .
Constraints
For of the testdata, .
For of the testdata, .
For the other of the testdata, .
For of the testdata, , , and each of the given numbers does not exceed .
Time limit: 1 second, 256 MB. Lanqiao Cup 2018, 9th Provincial Contest.
Translated by ChatGPT 5