304918: CF934B. A Prosperous Lot

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A Prosperous Lot

题意翻译

输入一个数 $k$ ($1 <= k <= 10^{6}$ ),输出任意一个每个数位上的数字环之和等于 $k$ 的正整数(要求小于$10^{18}$ )。如果不存在输出 $-1$ 。 ($0$ 有 $1$ 个环, $1$ 没有环,$2$ 没有环, $3$ 没有环, $4$ 有 $1$ 个环, $5$ 没有环, $6$ 有 $1$ 个环, $7$ 没有环, $8$ 有 $2$ 个环, $9$ 有 $1$ 个环) 感谢@Tweetuzki 提供的翻译

题目描述

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. Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony. He would like to find a positive integer $ n $ not greater than $ 10^{18} $ , such that there are exactly $ k $ loops in the decimal representation of $ n $ , or determine that such $ n $ does not exist. 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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF934B/ef09358ad2ff9bd7af31e67d589f7cc1105bcc74.png)

输入输出格式

输入格式


The first and only line contains an integer $ k $ ( $ 1<=k<=10^{6} $ ) — the desired number of loops.

输出格式


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 $ 10^{18} $ .

输入输出样例

输入样例 #1

2

输出样例 #1

462

输入样例 #2

6

输出样例 #2

8080

Input

题意翻译

输入一个数 $k$ ($1 <= k <= 10^{6}$ ),输出任意一个每个数位上的数字环之和等于 $k$ 的正整数(要求小于$10^{18}$ )。如果不存在输出 $-1$ 。 ($0$ 有 $1$ 个环, $1$ 没有环,$2$ 没有环, $3$ 没有环, $4$ 有 $1$ 个环, $5$ 没有环, $6$ 有 $1$ 个环, $7$ 没有环, $8$ 有 $2$ 个环, $9$ 有 $1$ 个环) 感谢@Tweetuzki 提供的翻译

加入题单

上一题 下一题 算法标签: