贪心
先构造最大的,将s拆成9的倍数和余数,前面排列9的倍数个9再加上一个余数,最后排0
然后把最大的放余数位置的数减去1,然后后面填上0,最后填上1,再做一次翻转,得到最小的
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef complex<ld> point;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
#define CLR(x,y) memset(x,y,sizeof(x))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define MID(x,y) (x+((y-x)>>1))
#define eps 1e-9
#define INF 0x3f3f3f3f
#define LLINF 1LL<<62
template<class T>
inline bool read(T &n)
{
T x = 0, tmp = 1; char c = getchar();
while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
if(c == EOF) return false;
if(c == '-') c = getchar(), tmp = -1;
while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar();
n = x*tmp;
return true;
}
template <class T>
inline void write(T n)
{
if(n < 0)
{
putchar('-');
n = -n;
}
int len = 0,data[20];
while(n)
{
data[len++] = n%10;
n /= 10;
}
if(!len) data[len++] = 0;
while(len--) putchar(data[len]+48);
}
//-----------------------------------
int main()
{
int n,s;
read(n),read(s);
if(n==1 && !s){cout<<0<<' '<<0;return 0;}
if(n*9<s || !s){cout<<-1<<' '<<-1;return 0;}
string st;
while(s>0)
{
st+=min(9,s)+'0';
s-=min(9,s);
}
string st1=st;
while(st1.size()!=n)
st1+='0';
if(st.size()!=n)
{
st[st.size()-1]--;
for(int i=n-st.size(); i>=2; i--)
st+='0';
st+='1';
}
reverse(st.begin(),st.end());
cout<<st<<' '<<st1;
}