#P11229. Minimum Positive Integer from Sticks
Minimum Positive Integer from Sticks
Minimum Positive Integer from Sticks
Little S loves to collect small sticks. After collecting n sticks of equal length, he decides to use them to form digits. Each digit is built using a fixed number of sticks as shown below:
Digit | Sticks Required |
---|---|
0 | 6 |
1 | 2 |
2 | 5 |
3 | 5 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 3 |
8 | 7 |
9 | 6 |
Your task is to help Little S form a positive integer which satisfies the following conditions:
- Exactly n sticks are used to form the number.
- The number does not have any leading zero.
- Among all numbers that satisfy the above conditions, the formed number should be as small as possible.
If no positive integer can be formed using exactly n sticks, output -1
.
Note: All formulas in this problem are written in \(\LaTeX\)
format. For example, the conditions can be summarized as:
\(\text{Use exactly } n \text{ sticks, } \; n \in \mathbb{Z}^{+} \).
\(\text{If } n < 2 \text{ or no combination exists, output } -1\).
inputFormat
The input consists of a single line containing an integer n (\(1 \leq n \leq 10^3\)).
outputFormat
Output the smallest positive integer that can be formed using exactly n sticks according to the rules. If no such number exists, output -1
.
sample
1
-1