#P11229. Minimum Positive Integer from Sticks

    ID: 13298 Type: Default 1000ms 256MiB

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:

DigitSticks Required
06
12
25
35
44
55
66
73
87
96

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