自认为代码还比较简单,没有很多变量,纯贪心
#include<bits/stdc++.h>
using namespace std;
int m,sum;
void solve1(int sum,int m){
if(sum<=(m-1)*9){
cout<<1;
sum--;
}
else{
cout<<sum-(m-1)*9;
sum-=sum-(m-1)*9;
}
m--;
while(m--){
int t=sum-m*9;
if(t<0) t=0;
cout<<t;
sum-=t;
}
cout<<" ";
}
void solve2(int sum,int m){
while(m--){
if(sum>=9){
cout<<9;
sum-=9;
}
else{
cout<<sum;
sum=0;
}
}
}
int main(){
cin>>m>>sum;
if(m==1 && sum==0){
cout<<0<<" "<<0<<endl;
return 0;
}
if(sum>m*9 || sum==0){
cout<<-1<<" "<<-1<<endl;
return 0;
}
solve1(sum,m);
solve2(sum,m);
return 0;
}