#P6014. [CSGRound3] 斗牛
[CSGRound3] 斗牛
Description
Given cards, each with a value from . You need to choose of them such that their sum is a multiple of . The ones digit of the sum of the remaining two cards is the score you obtain. In particular, if the sum of these two cards is a multiple of , then the score is , which is also called “Niu Honghong”. If no choice of cards can make a multiple of , then the score is , which is also called “Niu Bu Long”.
Since Little Z wants to play more happily, you need to write a program to help Little Z know the score within second.
Input Format
The first line contains an integer , indicating there are cards in total.
The second line contains integers, representing the values of these cards.
Output Format
Output one integer in a single line, representing the score of this hand. The score ranges from .
5
10 10 10 2 3
5
5
3 4 5 6 7
0
Hint
Sample 1 Explanation
(three cards) can form a multiple of , and .
Sample 2 Explanation
Any three cards cannot form a multiple of .
Constraints
This problem uses bundled tests.
- Subtask 1 (50 points): .
- Subtask 2 (30 points): .
- Subtask 3 (20 points): no special constraints.
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号