CF934B.A Prosperous Lot

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 1018, 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.

除了年兽之外,还有一种名为“祟”的妖怪,它会吓唬孩子并使他们生病。父母会将钱装在红色红包里送给孩子,并把红包放在孩子的枕头下,这样当“祟”靠近时,就会被红包里的神仙吓跑。

大班班正在为该给多少钱而犹豫不决。他认为“环”是幸运的,因为它象征着团结与和谐。

他希望找到一个不超过 101810^{18} 的正整数 nn,使得 nn 的十进制表示中恰好含有 kk 个“环”;若不存在这样的 nn,则需判定其不存在。

所谓“环”,是指用阿拉伯数字书写的十进制数字中,由笔画所围成的平面封闭区域。例如:数字 4 中有 1 个环,数字 8 中有 2 个环,而数字 5 中没有环。所有数字的具体形状参见下图:

输入格式

The first and only line contains an integer k (1 ≤ k ≤ 106) — the desired number of loops.

第一行且唯一一行包含一个整数 kk(1 ≤ k ≤ 1061 \le k \le 10^6)—— 所需的循环次数。

输出格式

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.

输出一个整数——若不存在满足条件的 nn,则输出 −1-1;否则输出任意一个满足条件的 nn。在后一种情况下,你的输出应为一个不超过 101810^{18} 的正十进制整数。

输入输出样例

  • 输入#1

    2

    输出#1

    462
  • 输入#2

    6

    输出#2

    8080

输入解题思路,AI测评打分。不知道怎么写?

首页