CF934B A Prosperous Lot

    • 107通过
    • 317提交
  • 题目来源 CodeForces 934B
  • 评测方式 RemoteJudge
  • 标签 贪心
  • 难度 普及-
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    输入一个数 $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.

    输入输出格式

    输入格式:

    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
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。