CF 277.5 C.Given Length and Sum of Digits.. 构造

时间:2022-01-31 21:10:35
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
int a[];
int main()
{
int m,s;
cin>>m>>s;
if(m==&&s==)
{
cout<<"0 0"<<endl;
return ;
}
if(s==)
{
cout<<"-1 -1"<<endl;
return ;
}
if(s>*m)
{
cout<<"-1 -1"<<endl;
return ;
}
int t=s-;//精湛的-1 屌不屌?
for(int i=;i<m;i++)
{
int r=min(t,);
a[i]=r;
t-=r;
}
a[m-]++;
for(int i=m-;i>=;i--)
cout<<a[i];
cout<<" ";
t=s;
for(int i=;i<m;i++)
{
int r=min(,t);
cout<<r;
t-=r;
}
cout<<endl;
return ;
}