#P2192. HXY玩卡片
HXY玩卡片
Description
HXY has some cards, each labeled with the digit or .
She can choose some of these cards and arrange them in a row to form the largest possible number that is divisible by .
This number must be a valid non-negative integer, meaning it cannot have a leading ; that is, cannot be the first digit of the sequence.
Exceptionally, the integer is allowed.
If no such number can be formed, output .
Input Format
The first line contains the number of cards .
The second line contains the digits (each is either or ).
Output Format
Output a single line: if it is possible, print the number; otherwise, print .
4
5 0 5 0
0
11
5 5 5 5 5 5 5 5 0 5 5
5555555550
2
5 5
-1
Hint
Constraints:
For of the testdata, .
For of the testdata, all given digits are .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号