-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path489C.cpp
87 lines (83 loc) · 1.64 KB
/
489C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*--------------------- Author - Akshit ----------------------*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<cstdlib>
#include<numeric>
#include<set>
#include<map>
#include<deque>
#include<climits>
#include<cassert>
#include<cctype>
#include<ctime>
#include<iterator>
#include<iomanip>
#include<functional>
#include<fstream>
#include<ostream>
#include<istream>
#include<sstream>
using namespace std;
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d",n)
#define pfln(n) printf("%d\n",n)
#define vi vector <int >
#define pb push_back()
#define debug(n) printf("n = %d\n",n)
#define PI 3.14159265358979
#define LL 1000000007
bool ifpossible (int s, int m){
return (s>=0 && s<=9*m);
}
int ans1[101];
int ans2[101];
int main()
{
std::ios_base::sync_with_stdio(false);
int m,s;
cin>>m>>s;
int sum = s;
int idx = 0;
if(m == 1 && s == 0){
cout<<"0 0\n";
}
else if(s>9*m || s==0 )
cout<<"-1 -1\n";
else{
for(int j = 1 ; j <= m ; j++){
for(int i = 0 ; i <= 9 ; i++){
if(ifpossible(s-i,m-j) && !(j==1 && i == 0)){
ans1[idx++] = i;
s-=i;
break;
}
}
}
idx = 0;
for(int j = 1 ; j <= m ; j++){
for(int i = 9 ; i >=0 ; i--){
if(ifpossible(sum-i,m-j) && !(j == 1 && i == 0)){
ans2[idx++] = i;
sum-=i;
break;
}
}
}
for(int i = 0 ; i < m ; i++){
cout<<ans1[i];
}
cout<<" ";
for(int i = 0 ; i < m ; i++){
cout<<ans2[i];
}
}
return 0;
}