307641: CF1388B. Captain Flint and a Long Voyage

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Captain Flint and a Long Voyage

题意翻译

### 题目描述 若有一个 $n$ 位正整数 $x$,定义 $k$ 的值为将 $x$ 的每一位上的数字转换为二进制(不含前导 $0$)。比如 $x=729$ 时,$k=111101001$。将 $k$ 的后 $n$ 位截去得到 $r$。比如 $x=729$ 时,$r=111101$。 现在给定 $n$,你需要找到 $r$ 最大时 $x$ 的最小值。 ### 输入格式 第一行一个整数 $T(1\le t\le1000)$,表示数据组数。 接下来 $T$ 行,每行一个正整数 $n(1\le n\le 10^5)$。 ### 输出格式 对于每组数据,输出一行一个正整数,表示 $r$ 最大时 $x$ 的最小值。 ### 数据范围 $1\le t\le1000$,$1\le n\le 10^5$。 数据保证所有数据中的 $n$ 之和不超过 $2\times10^5$。 Translated by [cmll02](https://www.luogu.com.cn/user/171487).

题目描述

Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it. In the beginning, uncle Bogdan wrote on a board a positive integer $ x $ consisting of $ n $ digits. After that, he wiped out $ x $ and wrote integer $ k $ instead, which was the concatenation of binary representations of digits $ x $ consists of (without leading zeroes). For example, let $ x = 729 $ , then $ k = 111101001 $ (since $ 7 = 111 $ , $ 2 = 10 $ , $ 9 = 1001 $ ). After some time, uncle Bogdan understood that he doesn't know what to do with $ k $ and asked Denis to help. Denis decided to wipe last $ n $ digits of $ k $ and named the new number as $ r $ . As a result, Denis proposed to find such integer $ x $ of length $ n $ that $ r $ (as number) is maximum possible. If there are multiple valid $ x $ then Denis is interested in the minimum one. All crew members, including captain Flint himself, easily solved the task. All, except cabin boy Kostya, who was too drunk to think straight. But what about you? Note: in this task, we compare integers ( $ x $ or $ k $ ) as numbers (despite what representations they are written in), so $ 729 < 1999 $ or $ 111 < 1000 $ .

输入输出格式

输入格式


The first line contains a single integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. Next $ t $ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $ n $ ( $ 1 \le n \le 10^5 $ ) — the length of the integer $ x $ you need to find. It's guaranteed that the sum of $ n $ from all test cases doesn't exceed $ 2 \cdot 10^5 $ .

输出格式


For each test case, print the minimum integer $ x $ of length $ n $ such that obtained by Denis number $ r $ is maximum possible.

输入输出样例

输入样例 #1

2
1
3

输出样例 #1

8
998

说明

In the second test case (with $ n = 3 $ ), if uncle Bogdan had $ x = 998 $ then $ k = 100110011000 $ . Denis (by wiping last $ n = 3 $ digits) will obtain $ r = 100110011 $ . It can be proved that the $ 100110011 $ is the maximum possible $ r $ Denis can obtain and $ 998 $ is the minimum $ x $ to obtain it.

Input

题意翻译

### 题目描述 若有一个 $n$ 位正整数 $x$,定义 $k$ 的值为将 $x$ 的每一位上的数字转换为二进制(不含前导 $0$)。比如 $x=729$ 时,$k=111101001$。将 $k$ 的后 $n$ 位截去得到 $r$。比如 $x=729$ 时,$r=111101$。 现在给定 $n$,你需要找到 $r$ 最大时 $x$ 的最小值。 ### 输入格式 第一行一个整数 $T(1\le t\le1000)$,表示数据组数。 接下来 $T$ 行,每行一个正整数 $n(1\le n\le 10^5)$。 ### 输出格式 对于每组数据,输出一行一个正整数,表示 $r$ 最大时 $x$ 的最小值。 ### 数据范围 $1\le t\le1000$,$1\le n\le 10^5$。 数据保证所有数据中的 $n$ 之和不超过 $2\times10^5$。 Translated by [cmll02](https://www.luogu.com.cn/user/171487).

加入题单

上一题 下一题 算法标签: