挺难:
#include<bits/stdc++.h>
using namespace std;
const int cost[]={6,2,5,5,4,5,6,3,7,6};
int n;
bool inseg(int bef,int ob,int aft)
{return bef<=ob && ob<=aft;}
void Max()
{
cout<<7*(n%2)+!(n%2);
for(int i=1;i<n/2;i++) cout<<1;
cout<<endl;
}
int main()
{
//freopen("matchsticks.in" ,"r",stdin );
//freopen("matchsticks.out","w",stdout);
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
int temp=ceil(n/7.0),N=n;
for(int i=1;i<=temp;i++)//8 的数量
for(int j=0;j<10;j++)//枚举取的数字
if(i+j>1 && inseg(2*(temp-i),n-cost[j],7*(temp-i)))
{cout<<j,n-=cost[j];break;}
n=N;
cout<<' ';
Max();
}
return 0;
}(⁎⁍̴̛ᴗ⁍̴̛⁎)