1071-数字的空洞

描述

 

在个位数中:04689有一个共同的特征:数形上存在空洞,其中8有两个相切的空洞。一个非负整数具有多个空洞,给定一个空洞数目h0 ≤ h ≤ 510),请你写一个计算机程序来找出能产生这些空洞的数,要求数应尽可能小,且无前导零。

 

输入

 

一行输入一个非负整数h,表示空洞的数目。

 

输出

 

能产生这些空洞的最小数。

 

注意:输出部分的结尾要求包含一个多余的空行。

 

样例输入

0

1

15

70

样例输出

1

0

48888888

88888888888888888888888888888888888

#include<iostream>

using namespace std;



int main()

{

    int n,i;

    while(cin>>n)

    {

        if(n==0) cout<<"1"<<endl;

        else if(n==1) cout<<"0"<<endl;

        else if(n==2) cout<<"8"<<endl;

        else if(n==3) cout<<"48"<<endl;

        else

        {

            if(n%2!=0) cout<<"4";

            for(i=0;i<n/2;i++)

                cout<<"8";

            cout<<endl;

        }

    }

    return 0;

}

  

你可能感兴趣的:(数字)