934B.md (1505B)
1 Source: https://codeforces.com/problemset/problem/934/B 2 3 B. A Prosperous Lot 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside. 22 23 Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony. 24 25 He would like to find a positive integer *n* not greater than 1018, such that there are exactly *k* loops in the decimal representation of *n*, or determine that such *n* does not exist. 26 27 A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms. 28 29  30 31 Input 32 33 The first and only line contains an integer *k* (1 ≤ *k* ≤ 106) — the desired number of loops. 34 35 Output 36 37 Output an integer — if no such *n* exists, output -1; otherwise output any such *n*. In the latter case, your output should be a positive decimal integer not exceeding 1018. 38 39 Examples 40 41 Input 42 43 ``` 44 2 45 ``` 46 47 Output 48 49 ``` 50 462 51 ``` 52 53 Input 54 55 ``` 56 6 57 ``` 58 59 Output 60 61 ``` 62 8080 63 ```