Display The Number
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You have a large electronic screen which can display up to 998244353998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 77 segments which can be turned on and off to compose different digits. The following picture describes how you can display all 1010 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 11, you have to turn on 22 segments of the screen, and if you want to display 88, all 77 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 nn 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 nn segments.
Your program should be able to process tt different test cases.
Input
The first line contains one integer tt (1≤t≤1001≤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 nn (2≤n≤1052≤n≤105) — the maximum number of segments that can be turned on in the corresponding testcase.
It is guaranteed that the sum of nn over all test cases in the input does not exceed 105105.
Output
For each test case, print the greatest integer that can be displayed by turning on no more than nn segments of the screen. Note that the answer may not fit in the standard 3232-bit or 6464-bit integral data type.
Example
input
代码语言:javascript复制2
3
4
output
代码语言:javascript复制7
11
A题笔者可是想了十分钟,太菜了的原因吧,我们观察可得1的成本是2,7的成本是3,其他的都比这两个数高,所以但凡我有2我就多一位,这肯定是最优解,但是如果我只剩下3,我一定取7,其实这里就可以想象最优解一定是形如1111111,或者111117之类的,对吗,不对,因为7111111好像更优,所以应该是偶数就是都1,%3=0的数就首位为7,笔者的代码写的麻烦了,不过是同一个意思~
代码语言:javascript复制#include<bits/stdc .h>
using namespace std;
#define ll long long
#define rg register ll
ll a[15]={6,2,5,5,4,5,6,3,7,6};
int main()
{
ll t;
cin>>t;
for(rg i=1;i<=t;i )
{
ll x,ans=0;
cin>>x;
string s;
for(rg j=1;j<=x/2-1;j )s ='1';
ll tep=x-(x/2-1)*2,maxx=0;
for(rg j=0;j<=9;j )
{
if(tep>=a[j])maxx=max(maxx,j);
}
s =maxx 48;
string tepp=s;
reverse(s.begin(),s.end());
if(tepp<s)cout<<s<<endl;
else cout<<tepp<<endl;
}
while(1)getchar();
return 0;
}