zoukankan      html  css  js  c++  java
  • Codeforces 934 B.A Prosperous Lot

     
    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.

    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
    Copy
    2
    output
    462
    input
    Copy
    6
    output
    8080
     

    代码:
     1 //B
     2 #include<iostream>
     3 #include<cstring>
     4 #include<cstdio>
     5 #include<cmath>
     6 #include<algorithm>
     7 #include<queue>
     8 using namespace std;
     9 #define ll long long
    10 int main(){
    11     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    12     int n;
    13     cin>>n;
    14     if(n>36) cout<<-1<<endl;
    15     else{
    16         for(int i = 0;i < n/2;i++)
    17             cout<<8;
    18         if(n%2==1) cout<<6;
    19         cout<<endl;
    20     }
    21 }
  • 相关阅读:
    ie8 不能加载dll的问题解决
    Delphi 释放数组中的数据
    CSS: 首字母字体变大时下划线不对齐的解决方法
    谈谈一些有趣的CSS题目(十三)-- 巧妙地制作背景色渐变动画!
    吃透css3之3d属性--perspective和transform
    vue-cli中的webpack配置
    转载 webstrom识别 React语法
    CSS 布局整理(************************************************)
    巧用chrome开发者工具
    详解Webpack2的那些路径
  • 原文地址:https://www.cnblogs.com/ZERO-/p/9723047.html
Copyright © 2011-2022 走看看