思路:
假设 minc = ak = min { ai | 1 ≤ i ≤ 9 } ,num = k + k * 101 + k * 102 + … + k * 10minc(即数num是由minc+1个k组成),则题目所求的数为 min { 10a0+1 , num };
代码:
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rpn(i,n) for(int i=1;i<=n;i++)
const int N=10;
const int MAX_C=100005;
int ans[N];
int main(){
IOS;
int t;
cin>>t;
rp(i,t){
rp(j,10) cin>>ans[j];
int minc=MAX_C,num;
for(int j=1;j<=9;j++){
if(ans[j]<minc){
minc=ans[j];
num=j;
}
}
string s1="10",s2="";
while(ans[0]--) s1+="0";
char c=num+'0';
s2+=c;
while(ans[num]--) s2+=c;
int len1=s1.length(),len2=s2.length();
cout<<((len1==len2)?(s1<s2?s1:s2):(len1<len2?s1:s2))<<'
';
}
return 0;
}