CF 1295——A.Display The Number【构造、简单思维】

纵然是瞬间 提交于 2020-01-31 04:34:20

题目传送门


You have a large electronic screen which can display up to 998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 7 segments which can be turned on and off to compose different digits. The following picture describes how you can display all 10 decimal digits:

在这里插入图片描述

As you can see, different digits may require different number of segments to be turned on. For example, if you want to display 1, you have to turn on 2 segments of the screen, and if you want to display 8, all 7 segments of some place to display a digit should be turned on.

You want to display a really large integer on the screen. Unfortunately, the screen is bugged: no more than n segments can be turned on simultaneously. So now you wonder what is the greatest integer that can be displayed by turning on no more than n segments.

Your program should be able to process t different test cases.


Input

The first line contains one integer t (1≤t≤100) — the number of test cases in the input.

Then the test cases follow, each of them is represented by a separate line containing one integer n (2≤n≤105) — the maximum number of segments that can be turned on in the corresponding testcase.

It is guaranteed that the sum of n over all test cases in the input does not exceed 105.


Output

For each test case, print the greatest integer that can be displayed by turning on no more than n segments of the screen. Note that the answer may not fit in the standard 32-bit or 64-bit integral data type.


input

2
3
4


output

7
11


题意

  • 每个数字如图由木棒组成,给出一定数量的木棒,求出可以组成的最大数

题解

  • 很显然 22 个木棒即可组成 1133 个木棒组成 77,位数越多,数字越大
  • 偶数直接全转换成 11
  • 奇数将第一个 11,变成 77 即可

AC-Code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		int	t = 0;
		if (!(n & 1))
			t = n / 2;
		else
			t = (n - 3) / 2;
		n = n - t * 2;
		if (n)
			printf("7");
		for (int i = 1; i <= t; ++i)
			printf("1");
		puts("");
	}
	return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!