B. A Prosperous Lot
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

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

Output

Output an integer — if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positivedecimal integer not exceeding 1018.

Examples
input
2
output
462
input
6
output
8080
题目大意:每个数字都有其封闭空间的数量,现在要求给出一个不超过10^18的正数,使得这个数字所有的数位上的数字的封闭区间的个数和等于k.
分析:水题啊......如果k > 36就无解了. 不然肯定先填8,n为奇数就填一个4.
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; typedef long long ll;
int n; int main()
{
scanf("%d",&n);
if (n > )
puts("-1");
else
{
int num1 = n / ;
int num2 = n - num1 * ;
for (int i = ; i <= num1; i++)
printf("");
for (int i = ; i <= num2; i++)
printf("");
} return ;
}
 

Codeforces 934.B A Prosperous Lot的更多相关文章

  1. Codeforces 934 A.Compatible Pair

    http://codeforces.com/contest/934 A. A Compatible Pair   time limit per test 1 second memory limit p ...

  2. Codeforces 934.C A Twisty Movement

    C. A Twisty Movement time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces 934.D A Determined Cleanup

    D. A Determined Cleanup time limit per test 1 second memory limit per test 256 megabytes input stand ...

  4. Codeforces 934.A A Compatible Pair

    A. A Compatible Pair time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. Codeforces 934 C.A Twisty Movement-前缀和+后缀和+动态规划

    C. A Twisty Movement   time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces 934 最长不递减子序列 多项式系数推导

    A B C 给你一个长度为N的01串 你可以翻转一次任意[L,R]的区间 问你最长的不递减序列为多少长 处理出1的前缀和 和2的后缀和 然后N^2 DP 处理出 [L,R]区间的最长不递增序列 #in ...

  7. Codeforces Round #462 (Div. 2) B-A Prosperous Lot

    B. A Prosperous Lot time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Codeforces 934D/933B - A Determined Cleanup

    传送门:http://codeforces.com/contest/934/problem/D 给定两个正整数p(p≥1).k(k>1).多项式f(x)的系数的取值集合为{0,1,2,...,k ...

  9. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

随机推荐

  1. Session的生命同期

    一.什么是Session,怎么用 Session是存放用户与web服务器之间的会话,即服务器为浏览器开辟的存储空间. 由于浏览器与服务器之间的会话是无状态(无状态的意思是会话之间无关联性,无法识别该用 ...

  2. Sublime Text3的快捷键和插件

    今天重装了一下Sublime Text3,发现了一个不错的网站,关于Sublime Text3的插件安装介绍的很详细,还有右键增强菜单和浏览器打开快捷键的创建.奉上链接 http://www.cnbl ...

  3. Scala构建元数据

    反射方式构建元数据: 通过反射来获取RDD中的Schema信息.这种方式适合于列名(元数据)已知的情况下 步骤: 1.SparkConf配置环境 2.SparkContext初始化上下文 3.SQLC ...

  4. stdio中牛逼的写法

    用空间换时间的典型 /* * NOTE! This ctype does not handle EOF like the standard C * library is required to. */ ...

  5. POJ:2395-Out of Hay

    Out of Hay Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18780 Accepted: 7414 Descripti ...

  6. 单源次短路径:poj:3255-Roadblocks

    Roadblocks Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17521 Accepted: 6167 Descripti ...

  7. Android 工具类 异常处理类CrashHandler

    1.整体分析 1.1.源代码如下,可以直接Copy. public class CrashHandler implements Thread.UncaughtExceptionHandler { pr ...

  8. 20145202马超 《Java程序设计》第七周学习总结

    Arrays:用于操作数组的工具类. 里面都是静态方法. asList:将数组变成list集合. 把数组变成集合的好处:可以使用集合的思想来操作数组中的元素. 将数组变成集合的时候不可以使用集合的增删 ...

  9. 二、mysql数据库之基本操作和存储引擎

    一.知识储备 数据库服务器:一台计算机(对内存要求比较高) 数据库管理系统:如mysql,是一个软件 数据库:oldboy_stu,相当于文件夹 表:student,scholl,class_list ...

  10. Android Stadio 导入moudle 不显示

    Android Stadio 导入moudle 不显示,moudle 里面的java类也没有识别,只当是普通的txt文件. 后来,我发现,每个moudle 都有一个.iml 文件~ 然后我就随便翻翻配 ...