cf462 A Compatible Pair

找多少個圈,我記得小學找規律的題目

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 positive decimal integer not exceeding 1018.

Examples
Input
2
Output
462
Input
6
Output
8080

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define f(i,l,r) for(int i=l;i<=r;i++)
#define g(i,l,r) for(int i=l;i>=r;i--)
 //888888888888888888 18* 2  === 36

int main()
{
	int n;
	cin>>n;
	if(n>36)cout<<-1<<endl;
	else
	{
		if(n%2==1) cout<<1;
		f(i,1,n/2) cout<<8;
		cout<<endl;
	}
	return 0;
}

未來的我一定會感謝現在正在成長的我

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章