字典序决定的第 k 大所以优先枚举a,计算出对于每个a合法的b的范围,c可以由 a b 相加得到
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
void getans(int a,int b){
cout<<a<<' '<<'+'<<' '<<b<<' '<<'='<<' '<<a+b<<endl;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T=1;cin>>T;
while(T--){
int a,b,c;cin>>a>>b>>c;
ll k;cin>>k;
bool ok=false;
for(int i=pow(10,a-1);i<pow(10,a);i++){
//c由 a b 确定所以不必管c
int L=max(pow(10,b-1),pow(10,c-1)-i);
int R=min(pow(10,c)-i-1,pow(10,b)-1);
if(L>R)continue;
int now=R-L+1;
if(now>=k){
getans(i,L+k-1);
ok=true;
break;
}
k-=now;
}
if(!ok)cout<<-1<<endl;
}
return 0;
}