Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stack>
- #include <math.h>
- #include <time.h>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <set>
- #include <iomanip>
- #include <vector>
- #include <map>
- #include <cassert>
- #include <queue>
- #include <tuple>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- #define forn(i, n) for (int i = 0; i < int(n); ++i)
- #define pb push_back
- #define mp make_pair
- #define shek_shek _DEBUG
- #define all(v) v.begin(),v.end()
- #define EPS 1e-9
- #define PI 3.1415926535897932384626433832795
- const int N = 150000;
- int a[N];
- long long sum[N + 1];
- int main () {
- int m, s;
- cin >> m >> s;
- if ((s == 0 && m > 1) ||
- (s > m * (s >= 10 ? 9 : s - 1))){
- cout << -1 << " " << -1;
- return 0;
- }
- int minsum = 0, maxsum = 0;
- string min_ans = "";
- for (int i = m - 1; i >= 0; i--) {
- if (s - minsum >= (s >= 10 ? 10 : s)) {
- min_ans += (s >= 10 ? '9' : (char)('0' + s - 1));
- minsum += (s >= 10 ? 9 : s - 1);
- } else {
- if (i > 0) {
- if (minsum == s - 1) {
- min_ans += '0';
- } else {
- min_ans += (char)('0' + (s - minsum) - 1);
- minsum = s - 1;
- }
- } else {
- min_ans += (char)('0' + (s - minsum));
- }
- }
- }
- reverse(all(min_ans));
- cout << min_ans;
- cout << " ";
- forn (i, m) {
- if (s - maxsum >= 10) {
- cout << 9;
- maxsum += 9;
- } else {
- cout << s - maxsum;
- maxsum += s - maxsum;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment