description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
ma = [] mi = [] def max_find_digit(nod, sum): global ma if nod > 1: t = sum - (nod - 1) * 9 if t > 9 or sum == 0: return if t < 0: t = 0 ma.append(t) if sum - t >= 0: max_find_digit(nod - 1, sum - t) return else: i...
ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if 9 * m < s or s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: mx = ( s // 9 * "9" + (str(s % 9) if s % 9 else "") + (m - s // 9 - (s % 9 != 0)) * "0" ) mn = "" for i in range(m): for j in range(i == 0, 10): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP BIN_OP VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys m, s = map(int, input().split()) if s == 0: if m == 1: print(0, 0) else: print(-1, -1) sys.exit() tas = s a = [0] * m a[0] = 1 tas -= 1 index = m - 1 while tas > 0: if index == -1: break a[index] += 1 if a[index] == 9: index -= 1 tas -= 1 res = [-1...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, m = map(int, input().split()) l = m if n != 1 and m == 0: print(-1, -1) elif n == 1 and m == 0: print(0, 0) elif m > n * 9: print(-1, -1) else: i = 0 s = [0] * n a = [0] * n while i < n and m != 0: s[i] += min(9, m) m -= s[i] i += 1 i = n - 1 while i > -1: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) min_num = [0] * m if s == 0 and m == 1: print("0 0") exit(0) if s == 0 or s > m * 9: print("-1 -1") exit(0) ci = len(min_num) - 1 s1 = s while s > 0: a = min(9, s) s -= a min_num[ci] = a ci -= 1 if min_num[0] == 0: min_num[0] = 1 for i in range(1,...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR WHILE ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
reader = input().split() s, m = map(int, reader) n = m - 1 s1 = s if m == 0 and s == 1: print(0, 0) elif m == 0 and s > 1: print(-1, -1) elif m > s * 9: print(-1, -1) else: result = "" while s1 - 1: s1 -= 1 if n > 9: result = "9" + result n -= 9 else: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING WHILE BIN_OP...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
from sys import exit m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) elif m > 1 and s == 0: print(-1, -1) else: e = s // 9 r = s % 9 q = e if r > 0: q += 1 if q > m: print(-1, -1) from sys import exit exit() mi, ma = "", "" if r ==...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys input = sys.stdin.readline m, s = map(int, input().split()) big, samll = [], [] if 1 <= s <= 9 * m: ss = s for i in range(m): v = min(9, ss) ss -= v big.append(v) samll = [*big] if samll[-1] == 0: last = -1 for i in range(len(samll) - 1, -1, -1): ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST IF NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(x) for x in input().split()] a = "" b = "" na = s nb = s if 9 * m < s or s == 0 and m != 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: for i in reversed(range(m)): x = na if x <= 9 and i != 0: x -= 1 y = nb if x >= 10: x = 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NUMBER ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
solutions = [] dp = {} firstCall = True def sumFromLength(s, l, sum=0): global solutions global dp global firstCall if l == 1: num = sum * 10 + s solutions.append(num) return else: till = -1 if firstCall: till = 0 firstCall = False ...
ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER FUNC_DEF NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMB...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = input().split(" ") m = int(m) s = int(s) m1 = m s1 = s l = [] sm = [] def large(m, s): if s >= 9 and 9 * m >= s: l.append(9) m = m - 1 s = s - 9 while m > 0: if s > 9: l.append(9) s = s - 9 m = m - 1 els...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR N...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
L = input().split() Len = int(L[0]) sum = int(L[1]) if sum == 0: if Len == 1: print("0 0") else: print("-1 -1") elif sum > 9 * Len: print("-1 -1") elif int(Len) == 1: print(str(sum), str(sum)) else: s = 0 out = "" for i in range(Len): if 9 * (s + 1) < sum: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
[m, s] = list(map(int, input().split())) if s == 0: if m > 1: print(-1, -1) else: print(0, 0) elif s > 9 * m: print(-1, -1) else: boro = "" choto = "" inc1 = 0 inc2 = 0 for i in range(m): for dig in range(10): if i == 0 and dig == 0: co...
ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
from sys import stdin, stdout read = lambda: map(int, stdin.readline().split()) I = lambda: stdin.readline() m, s = read() if s == 0 and m > 1 or s > 9 * m: print(-1, -1) exit() ans1 = ["0" for i in range(m)] ans2 = ["0" for i in range(m)] s1, s2 = s - 1, s for i in range(m - 1, 0, -1): if s1 > 9: ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if m == 1 and s == 0: print("0" + " " + "0") exit(0) if m == 0 or s > 9 * m or s == 0 and m != 1: print("-1" + " " + "-1") exit(0) sumV = 0 for i in range(m): temp = 1 if i == 0 else 0 while s - sumV - temp > 9 * (m - (i + 1)) and temp < 9: temp += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING STRING STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING STRING STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FO...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
line = input() m = int(line.split()[0]) s = int(line.split()[1]) l = [] p = [] if s == 0 and m == 1: print("0 0") elif s == 0 or s > 9 * m: print("-1 -1") elif m == 1: print(s, s) else: if s < 10: x = s * 10 ** (m - 1) y = 10 ** (m - 1) + s - 1 print(y, x) if s >= 10: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASS...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
[n, s] = [int(k) for k in input().split()] def dp(n, s): if s <= 9: mini = "1" if n >= 2: for k in range(n - 2): mini = mini + "0" mini = mini + str(s - 1) else: mini = str(s) maxi = str(s) for i in range(n - 1): ...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, s = map(int, input().split()) s2 = s if s == 0 and n == 1: print(0, 0) exit(0) if s == 0 and n > 1: print(-1, -1) exit(0) if n * 9 < s: print(-1, -1) exit(0) big = [] while s != 0: if s - 9 < 0: big.append(str(s)) break else: big.append("9") s -= 9 size...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def fail(): print(-1, -1) exit() read = lambda: map(int, input().split()) m, s = read() cnt = s // 9 x = s % 9 if cnt + (x > 0) > m: fail() if s == 0 and m > 1: fail() Max = "9" * cnt if x: Max += str(x) Max += "0" * (m - len(Max)) Min = list(Max[::-1]) if Min[0] == "0" and s: Min[0] = "1" ...
FUNC_DEF EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
line = input() ll = line.split() n = int(ll[0]) m = int(ll[1]) if n != 1 and m == 0 or 9 * n < m: print("-1 -1") else: h = "" for i in range(n): if m - 9 <= 0: break m -= 9 h += "9" h1 = h + str(m) H = len(h) for i in range(n - H - 1): h1 += "0" if...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys m, s = map(int, sys.stdin.readline().split()) if s == 0 and m == 1: print(0, 0) elif s >= 1 and s <= 9 * m: if s == 9 * m: print("9" * m, "9" * m) elif s >= 9 * m - 8: print(str(s % 9) + "9" * (m - 1), "9" * (m - 1) + str(s % 9)) else: t = (s - 1) // 9 i = s -...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 0 and m == 1: mn = 0 mx = 0 elif s == 0 and m != 1 or s > m * 9: mn = -1 mx = -1 elif s < 10 and m == 1: mn = s mx = s elif s < 10 and m > 1: mn = "1" + "0" * (m - 2) + str(s - 1) mx = str(s) + "0" * (m - 1) elif s // m == 9: mn = "9" * m ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] if m == 1 and s == 0: print(0, 0, sep=" ") elif m > 1 and s == 0: print(-1, -1, sep=" ") elif m > s: min_ = "" len_ = s len_ -= 1 curr = 0 while curr < m - 1: k = min(9, len_) min_ = str(k) + min_ curr += 1 len_ -= k ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER STRING IF VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if m == 1 and s == 0: print("0 0") elif s == 0 or m * 9 < s: print("-1 -1") else: smallest = ( "1" + "0" * (m - s // 9 - 1) + "9" * (s // 9) if s % 9 == 1 and s // 9 + 1 < m else ( str(s % 9) + "9" * (s // 9) if s // 9 + 1 == m...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = input().split() m = int(m) s = int(s) l1 = 0 l2 = 0 if s == 0: if m > 1: l1 -= 1 l2 -= 1 elif m == 1: l1 = 0 l2 = 0 elif 9 * m < s: l1 -= 1 l2 -= 1 elif s == 9 * m: l1 = l2 = 10**m - 1 elif s > 9: t = int(s / 9) if m <= 2: l1 += (s - 9 * t) * 10...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = (int(t) for t in input().split()) if (m, s) == (1, 0): print(0, 0) elif s > 9 * m or s < 1: print(-1, -1) elif s == 1: print("1" + "0" * (m - 1) + " " + "1" + "0" * (m - 1)) elif s == 9 * m: print("9" * m + " " + "9" * m) else: minim = [1] + [0] * (m - 1) tmp = s - 1 index = m - 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER STRING STRING BIN_OP STRING BIN_...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
s = input() s = s.split() l = int(s[0]) su = int(s[1]) if su < 1 or su > 9 * l: if su == 0 and l == 1: print(0, 0) else: print("-1 -1") else: list1 = l * ["0"] list2 = l * ["0"] su1 = su su2 = su i = 0 while su1 > 9: list1[i] = str(9) i = i + 1 su1...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR LIST STRING ASSIGN VAR BIN_OP VAR LIST STRING ASSIGN VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, m = map(int, input().split()) mm = m if m == 0 and n > 1: print("-1 -1") elif m == 0 and n == 1: print(0, 0) elif m > 9 * n: print("-1 -1") else: l = [0] * n maxi = "" mini = "" for i in range(n): l[i] = min(9, m) m = m - l[i] maxi += str(l[i]) if min(l) != 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
p, q = map(int, input().strip().split()) memo = {} arr = [] def dp(m, s, o): if s <= m * 9 and s >= 0: if o == 0: for i in range(1, 10): if dp(m - 1, s - i, o + 1) == 1: arr.append(i) break else: for i in range(10): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys def find_largest(m, s): ts = s ds = [(0) for i in range(m)] for i in range(m): ds[i] = str(min(ts, 9)) ts -= min(ts, 9) if ts > 0: return -1 else: d = "".join(ds) return int(d) def find_smallest(m, s): ts = s - 1 ds = [(0) for i in range...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL STRING VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] if m == 1 and s == 0: print(0, 0) elif 9 * m < s or 1 > s: print("-1 -1") else: mx = "" while len(mx) < m and sum([int(i) for i in mx]) + 9 <= s: mx += "9" if sum([int(i) for i in mx]) != s: mx += str(s - sum([int(i) for i in mx])) while l...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING WHILE FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR STRING IF FUNC_CALL VAR FUNC_CA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = input().split() m = int(m) s = int(s) ls = [] if s == 0 and m == 1: print("0 0") else: while s > 9: ls.append(9) s = s - 9 else: ls.append(s) ls1 = [str(i) for i in ls] a = "".join(ls1) if len(a) > m or a == "0": print("-1 -1") elif len(a) == m: ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
number1 = [] number2 = [] m, s = (int(x) for x in input().split()) y = s for i in range(m): for j in range(1, 11): if s - 10 + j >= 0: number1.append(10 - j) s = s - 10 + j break s = y for l in range(1, 10): if s - l <= 9 * (m - 1) and s - l >= 0: number2.appe...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(x) for x in input().split()] if s == 0 and m == 1: print("0 0") elif s < 1 or s > 9 * m: print("-1 -1") else: a = [1] + [0] * (m - 1) a_cnt = s - 1 for i in range(m - 1, -1, -1): if a_cnt > 9: a_cnt -= 9 a[i] += 9 else: a[i] += a_cnt ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
s, m = [int(i) for i in input().split()] if m == 0 and s != 1 or 9 * s < m: print(-1, -1) elif m == 0 and s == 1: print(0, 0) else: a = m // 9 b = m % 9 if b == 0: nmax = "".join(["9" * a, "0" * (s - a)]) nmin = "".join( [ "1" * bool(s - a > 0), ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL STRING LIST BIN_OP STRING VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys m, s = [int(x) for x in input().split()] if m > 1 and s == 0: print("-1 -1") sys.exit() f = [[([0] * (s + 1)) for j in range(10)] for i in range(0, m + 1)] for j in range(min(10, s + 1)): f[1][j][j] = 1 for i in range(2, m + 1): for j in range(min(10, s + 1)): for k in range(s + 1): ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIG...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
t = tuple(map(int, input().split())) a = t[1] // t[0] if t[0] == 1 and t[1] == 0: print("0 0") elif a > 9 or a == 9 and t[1] % t[0] != 0 or t[1] == 0: print("-1 -1") else: s = [a] * t[0] c = t[1] % t[0] for i in range(c): p = min(c, 9 - s[-1 - i]) c -= p s[-1 - i] += p i,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST VAR VAR NUMBER ASSIG...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def stringify(l): s = "" for i in l: s += str(i) return s m, s = map(int, input().split()) mc = m sc = s ans = [] rans = [] if sc > mc * 9 or sc == 0 and mc > 1: ans = [-1] rans = [-1] elif mc == 1 and sc == 0: ans = [0] rans = [0] else: while m: if s >= 9: ...
FUNC_DEF ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def solve(m, s): if s == 0 and m > 1: return -1, -1 if s == 0 and m == 1: return 0, 0 g = "" nines = "9" * (s // 9) remaining = str(s % 9) rest = remaining if remaining != "0" else "" cur_size = len(nines) + len(rest) if cur_size > m: return -1, -1 g = nines +...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
x, y = [int(t) for t in input().split()] num = y if y == 0 and x != 1 or y > 9 * x: print("-1 -1") exit() else: mini = 0 maxi = 0 n = 0 while y > 9: mini += 10**n * 9 y -= 9 n += 1 mini = mini + (y - 1) * 10**n + 10 ** (x - 1) n = x - 1 y = num while y > 9...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_O...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) op1 = [] op2 = [] def ismax(m, s): if s == 0 or s > 9 * m: return "-1" else: for i in range(m): if s > 9: op2.append("9") s -= 9 elif 1 <= s <= 9: op2.append(str(s)) s = 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def sum2(n, s): if s == 0 and n == 1: return "0 0" elif s == 0 and n != 1: return "-1 -1" numL = "" if s > 9 * n: return "-1 -1" numL += "9" * (s // 9) if len(numL) < n: numL += str(s - s // 9 * 9) numL += "0" * (n - len(numL)) numS = numL[::-1] zeros ...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR STRING IF VAR BIN_OP NUMBER VAR RETURN STRING VAR BIN_OP STRING BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a, b = list(map(int, input().split())) bb = b if a == 1 and b == 0: print("0 0") elif b == 0 or a == 0 or b > a * 9: print("-1 -1") else: ma = "" for i in range(a): if b > 9: ma = ma + str(9) b = b - 9 else: ma = ma + str(b) b = 0 b = b...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER ASSIGN VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def min_num(m, s): unit = 1 acum = 0 num = 0 for i in range(m): dig = 9 if i + 1 < m: while dig + acum >= s and dig >= 0: dig -= 1 else: while dig + acum > s and dig >= 0: dig -= 1 acum += dig num += dig * un...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETURN NUMBER RETURN VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def get_min(l, s): if s == 0 and l > 1 or s > 9 * l: print("-1 -1", end="") return nb_9 = min_nb_9 = s // 9 rest = min_rest = s % 9 if rest == 0 and nb_9 > 0: min_rest = 9 min_nb_9 -= 1 remaining_digits = l - min_nb_9 if remaining_digits < 0: print("-1 -1"...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING RETURN ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING RETURN IF VAR NUMBER EXPR FUNC_...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) elif s > 9 * m or s == 0: print(-1, -1) else: print( 10 ** (m - 1) + sum(10 ** (i // 9) for i in range(s - 1)), sum(10 ** (m - 1 - i // 9) for i in range(s)), )
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
l, s = map(int, input().split()) x = "" if s == 0: if l == 1: print(0, 0) exit() else: print(-1, -1) exit() while s >= 1: if s <= 9: x = x + str(s) s = 0 else: x = x + "9" s = s - 9 if l < len(x): print("-1 -1") else: a = x[::-1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR ST...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(x) for x in input().split()] a = s b = s if s < 0 or s > 9 * m: li = [str(-1), str(-1)] print(" ".join(li)) elif s == 0 and m > 1: li = [str(-1), str(-1)] print(" ".join(li)) elif m == 1: li = [str(s), str(s)] print(" ".join(li)) else: lstmin = [0] * m lstmax = [0] * m fo...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def valid(l, c): return l * 9 >= c m, s = map(int, input().split()) if not valid(m, s) or s == 0 and m > 1: print(-1, -1) exit() t, min_res = s, "" for i in range(m): for d in range(10): if (i > 0 or d > 0 or m == 1 and d == 0) and valid(m - i - 1, t - d): min_res += chr(ord("0") +...
FUNC_DEF RETURN BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) def max_(m, s): number_find = "" for j in range(m): i = 9 if s == 0: number_find += str(0) while i > 0: if s // i > 0: number_find += str(i) break i -= 1 s -= i return int(n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def possible(m, sum1): if sum1 >= 0 and sum1 <= 9 * m: return True m, s = [int(k) for k in input().split()] Found = True sum1 = s low = list() for i in range(m): if Found: for d in range(10): if i == 0 and d == 0: d = 1 if m == 1 and sum1 == 0: ...
FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR N...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) a = 0 ch = s ans1 = 0 ans2 = 0 fl = 0 fl2 = 0 if s == 0 and m != 1 or 9 * m < s: print(-1, -1) elif s == 0 and m == 1: print(0, 0) else: while a < m: if ch >= 9: ch -= 9 ans1 = ans1 * 10 + 9 else: ans1 = ans1 * 10 + ch ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR IF VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) max_res = "" min_res = "" if s == 0 and m == 1: print(0, 0) elif s == 0 or 9 * m < s: print(-1, -1) else: max_res = "9" * (s // 9) if s % 9 > 0: max_res += str(s % 9) min_res = max_res[::-1] max_res = max_res.ljust(m, "0") if len(min_res) < m: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys __author__ = "alexandrun" def process(m, s): if s == 0: if m == 1: return 0, 0 return -1, -1 q = s // 9 r = s % 9 if r == 0: cifMin = q else: cifMin = q + 1 if cifMin > m: return -1, -1 if cifMin == m: if r == 0: ...
IMPORT ASSIGN VAR STRING FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER RETURN NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER NUMBER IF VAR VAR IF VAR NUMBER RETURN BIN_OP STRING VAR BIN_OP STRING VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if 0 < s and s <= m * 9: mins = [0] * m mins[0] = 1 t = s - 1 it = m - 1 while it >= 0 and t > 0: if t > 9: mins[it] = 9 t -= 9 it -= 1 else: mins[it] += t it -= 1 t -= t maxs...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) min_num = "" max_num = "" if s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") elif s > m * 9: print("-1 -1") else: if s // 9 >= m - 1: max_num = "9" * (s // 9) + str(s % 9) * (m - s // 9) min_num = max_num[::-1] else: min_...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) min = [] max = [] d = 1 t = 1 s1 = s s2 = s if m >= 2 and s == 0: print("-1 -1") elif m == 1 and s == 0: print("0 0") elif s > 9 * m: print("-1 -1") else: while d <= m: if s1 - 9 * (m - d) > 0: w = s1 - 9 * (m - d) min.append(str(w)) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING WHILE VAR VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
length, sum_nums = list(map(int, input().split())) result = [] res_max = [] sum_nums2 = int(sum_nums) i = -1 Done = False if (length - 1) * 9 + 1 <= sum_nums and length * 9 >= sum_nums: for numeral in range(length - 1): result.append(9) a = list(result) result.append(sum_nums - sum(a)) print(""....
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a, b = map(int, input().split()) if a > 1 and not b: print("-1 -1") elif a == 1 and b == 0: print("0 0") else: b -= 1 i = a - 1 j = 0 s1 = list("1" + "0" * (a - 1)) s2 = list("1" + "0" * (a - 1)) while b: if s1[i] == "9": i -= 1 if s2[j] == "9": j ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP STRING ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def solve(m, s): if m == 1 and s == 0: return 0, 0 if s < 1 or s > 9 * m: return -1, -1 s1, s2 = s, s min_v, max_v = 0, 0 for i in range(1, m): for v in range(0 + (i == 1), 10): if 0 <= s1 - v and s1 - v <= 9 * (m - i): min_v = min_v * 10 + v ...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER NUMBER IF NUMBER BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a, b = map(int, input().split()) z = [0] * a z1 = [0] * a o = b - 1 if a == 1 and b == 0: print(0, 0) exit() for i in range(a): for j in range(9, -1, -1): if j <= b: z[i] = j break b -= z[i] for i in range(a - 1): for j in range(9, -1, -1): if j <= o: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR ASSIGN VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
l, suma = map(int, input().split()) smallest = [0] * l largest = [0] * l temp = suma if suma > 9 * l: print(-1, -1) elif suma == 0 and l == 1: print(0, 0) elif suma == 0: print(-1, -1) else: smallest[0] = 1 temp -= 1 for i in range(l - 1, -1, -1): if temp > 0 and temp <= 9: s...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def main(): m, s = map(int, input().split()) if not s: print(("0 0", "-1 -1")[m > 1]) elif s > 9 * m: print("-1 -1") else: l = ["9"] * (s // 9) if s % 9: l.append(str(s % 9)) l += ["0"] * (m - len(l)) ma = "".join(l) l.reverse() ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR STRING STRING VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP LIST STRING BIN_OP VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = list(map(int, input().split())) if s == 0: if m != 1: print(-1, -1) else: print("0" * m, "0" * m) elif s <= 9: if m == 1: print(s, s) else: maxs = [s] + [0] * (m - 1) mins = [1] + [0] * (m - 2) + [s - 1] print("".join(list(map(str, mins))), "".join(...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
inp = input() chars = inp.split() m = int(chars[0]) s = int(chars[1]) if s == 0 and m == 1: print("0 0") exit() if s < 1 or s > 9 * m: print("-1 -1") exit() if s > 9 * (m - 1): x = s - 9 * (m - 1) a = x for i in range(m - 1): a = a * 10 + 9 else: a = 10 ** (m - 1) s1 = s - 1 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, sm = map(int, input().split()) if sm == 0 and n == 1: print(0, 0) elif sm == 0 or sm > n * 9: print(-1, -1) else: big = "9" * (sm // 9) if sm % 9 > 0: big += str(sm % 9) zeroes = n - len(big) big += "0" * zeroes if zeroes == 0: small = big[::-1] else: sm -= 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s > 9 * m or s == 0 and m != 1: print(-1, -1) else: print( int(10 ** (m - 1) + ((s - 1) % 9 + 1) * 10 ** ((s - 1) // 9) - 1), int(10**m - int((10 - s % 9) * 10 ** (m - s // 9 - 1))), )
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) print( [ f"{int(10 ** (m - 1) + ((s - 1) % 9 + 1) * 10 ** ((s - 1) // 9) - 1)} {int(10 ** m - 10 ** (m - (s - 1) // 9 - 1) * (9 - (s - 1) % 9))}", "-1 -1", ][s > 9 * m or s < 1 and m != 1] )
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER STRING FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(lambda i: int(i), input().split()) if m == 1 and s == 0: print("0 0") elif s == 0 or s > 9 * m: print("-1 -1") else: a = [0] * m a[0], remain, idx = 1, s - 1, m - 1 while remain > 0: maxinc = 9 - (idx == 0) a[idx] += min(maxinc, remain) remain = remain - a[idx] + (...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_O...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] max_num = [0] * m if m == 1 and s == 0: print(0, 0) elif s < 1 or m * 9 < s: print(-1, -1) else: s1 = s for i in range(m): if s - 9 > 0: max_num[i] += 9 s -= 9 else: max_num[i] += s s -= s ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s < 1: print(-(m > 1), -(m > 1)), exit() if 9 * m < s: print(-1, -1), exit() def g(s): for i in range(m): v = min(9, s) yield str(v) s -= v a = "".join(g(s)) print(a[::-1] if a[-1] > "0" else "1" + "".join(g(s - 1))[-2::-1], a)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, const_s = map(int, input().split()) a = [] s = const_s for i in range(m - 1, -1, -1): k = min(s - i * 9, 9) if len(a) > 0: k = max(0, k) else: k = max(1, k) s -= k if s < 0: break a.append(k) if len(a) == m and s == 0: a = "".join([str(i) for i in a]) else: a =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR IF VAR NU...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) def f(m, s): if s > m * 9: return "-1 -1" elif s == 0 and m == 1: return "0 0" elif s * m == 0: return "-1 -1" else: high = [] while s > 0: r = min(s, 9) high.append(r) s -= r high += [...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETURN STRING IF BIN_OP VAR VAR NUMBER RETURN STRING ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
l = list(map(int, input().split(" "))) m = l[0] s = l[1] a = list() b = list() S = 0 n = 0 while n < m: if 9 + S <= s: a.append(9) S = S + 9 n = n + 1 elif 8 + S <= s: a.append(8) S = S + 8 n = n + 1 elif 7 + S <= s: a.append(7) S = S + 7 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().rstrip().split(" ")) if m == 1 and s == 0: print("0 0") elif s == 0 or s / m > 9: print("-1 -1") else: sum1 = s - 1 minimum = "" maximum = "" for i in range(m): x = min(9, s) s -= x maximum += str(x) for i in range(m - 1): x = min(9, su...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
length, sum_digits = [int(a) for a in input().strip().split()] l_num = 1 * 10 ** (length - 1) lnum_list = [int(a) for a in str(l_num)] if sum_digits > length * 9 or sum_digits == 0: if sum_digits == 0 and length == 1: print("0 0") else: print("-1 -1") elif sum_digits == 1: num = 1 * 10 ** (l...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) ar = [0] * m ar[0] = 1 sum1 = 1 if m == 1: if s > 9: print("-1 -1") else: print(s, s) else: dd = 0 for i in range(m - 1, 0, -1): if sum1 <= s: ar[i] += 9 sum1 += 9 if sum1 > s: ar[i] -= sum1 - s ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR NUMBER VAR NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s < 1 < m or s > 9 * m: print("-1 -1") elif m == 1 and s == 0: print("0 0") else: q, r = divmod(s, 9) p = "9" * q + (str(r) if r != 0 else "") p += "0" * (m - len(p)) q = p[::-1] i = q.rindex("0") if "0" in q else -1 q = list(map(int, q)) q[i + 1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR NUMBER FUNC_CALL VAR VAR STRING VAR BIN_OP STRING BIN_OP VAR FUNC_...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 0 and m == 1: print(0, 0) elif s < 1 or 9 * m < s: print(-1, -1) else: tot = s mini = "" maxi = "" add = 0 for i in range(m): if s > 9: mini += "9" s -= 9 else: mini += str(s - 1) s = 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR F...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) a = s if s == 0 and m != 1 or s / m > 9: print(-1, -1) elif m == 1: if s > 9: print(-1, -1) else: x, y = s, s print(x, y) else: mx = [] for i in range(m): if s > 9: mx.append(9) s = s - 9 elif s >= 1: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER E...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) elif s == 0 or s > 9 * m: print(-1, -1) else: e = s // m amax = [] for i in range(m): amax.append(e) l = s % m for i in range(m): if l > 0: amax[i] += 1 l -= 1 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys m, s = list(map(int, input().split())) if m is 1 and s is 0: print("0 0") sys.exit() if m * 9 < s or s is 0: print("-1 -1") sys.exit() max_val = [] max_n = 9 temp_s = s temp_m = m sum_ = 0 while temp_m is not 0: if temp_s >= max_n: temp_s = temp_s - max_n max_val.append(s...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) total = s k = m - 1 w = [] for i in range(m): if total >= 9: total -= 9 w.append(9) elif total <= 0: w.append(0) else: w.append(total) total -= total hh = w W = hh[::-1] if m == 1 and s == 0: print("0 0") elif s != sum(w) or s == 0...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def recur(m1, s1): global ans if m1 == 1: ans.insert(0, s1) return elif s1 > 9: ans.insert(0, 9) recur(m1 - 1, s1 - 9) else: ans.insert(0, s1 - 1) recur(m1 - 1, 1) def grecur(m1, s1): global gans if m1 == 1: gans.append(s1) return...
FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN IF VAR NUMBER EXP...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
x, y = [int(i) for i in input().split()] if x > 1 and y < 1 or x * 9 < y: print("-1 -1") else: k = y for i in range(x): s = max(0, k - (x - i - 1) * 9) if s == 0 and i == 0 and k != 0: s = 1 k = k - s print(s, end="") print(" ", end="") k = y for i in ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIG...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
A = input().split() m = int(A[0]) s = int(A[1]) if s == 0 and m == 1: print(0, 0) elif s < 1 or s > 9 * m: print(-1, -1) else: current = s big = [0] * m for i in range(0, m): if current <= 9: big[i] = current break else: big[i] = 9 curr...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) def solve(m, s): if m > 1 and s == 0: return -1, -1 if m == 1 and s == 0: return 0, 0 if m == 0 and s == 0: return -1, -1 if s > m * 9: return -1, -1 sorted_nums = [9] * (s // 9) if s % 9: sorted_nums.append(s % 9) ma...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER E...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def main(): line = input().split() m = int(line[0]) s = int(line[1]) digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] mini = [0] * m out1 = "" maxi = [0] * m out2 = "" if s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") elif s > 9 * m: prin...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING IF VAR NUMBER ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = input().split() m, s = int(m), int(s) largest = "" smallest = "" p = m q = s if s == 0 and m == 1: print("0 0") elif s == 0 or 9 * m < s: print("-1 -1") else: while m > 0: if s >= 9: largest = "9" + largest s = s - 9 elif s > 0 and s < 9: largest = ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP ST...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) n = s // 9 mod = s % 9 if mod == 0: digits = n else: digits = n + 1 if s == 0 and m == 1: print(0, 0) elif digits > m or s == 0: print(-1, -1) elif mod == 0: temp = 0 ma = "" ma += "9" * digits temp += digits ma += "0" * (m - digits) mi = "" i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER AS...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) mi = -1 ma = -1 a = s // 9 b = s % 9 if m == 1 and s == 0: mi = ma = 0 elif 1 <= s <= 9 * m: if a == m and b == 0: ma = 10**m - 1 else: ma = 10**m - 10 ** (m - a) + s % 9 * 10 ** (m - a - 1) if b == 0: if a == m: mi = 10**m - 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF NUMBER VAR BIN_OP NUMBER VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] k = ["1"] + ["0"] * (m - 1) k1 = ["0"] * m s1 = s flag = 0 if m == 1 and s == 0: flag = 1 print("0 0") if (m * 9 < s or s == 0) and flag == 0: flag = 1 print("-1 -1") else: for i in range(m - 1): ind = m - 1 - i j = 9 while s1 > 1: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) minimum = m * [0] maximum = m * [0] minimum[0] = 1 for num in range(1, s): for value in range(1, m + 1): if minimum[-value] != 9: minimum[-value] += 1 break for num in range(s): for value in range(0, m): if maximum[value] != 9: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 0: if m != 1: print(-1, -1) else: print(0, 0) else: min = [] max = 0 r = s c = 0 f = m - 1 if m * 9 < s: print(-1, -1) else: while r > 0: c += 1 if r >= 9: min.append(9) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER WHILE VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] s_1, m_1 = s, m min_list = [] max_list = [] min_str = "" max_str = "" if m == 1 and s == 0: print(0, 0) elif s == 0 or s > m * 9: print(-1, -1) else: while s > 9: max_list.append(9) s -= 9 m -= 1 if s > 0: max_list.append(s) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys m, s = map(int, sys.stdin.readline().split()) def get_max(m, s, digits=range(9, -1, -1)): if not 0 <= s <= 9 * m: return None if m == 1: return s for digit in digits: candidate = get_max(m - 1, s - digit) if candidate is not None: return f"{digit}{ca...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FUNC_CALL VAR NUMBER NUMBER NUMBER IF NUMBER VAR BIN_OP NUMBER VAR RETURN NONE IF VAR NUMBER RETURN VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR NONE RETURN VAR VAR RETURN NONE FUNC_DEF FUNC_CALL VAR NUMBER IF N...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, og_s = list(map(int, input().split())) maxn = "" if m == 1 and og_s == 0: print(0, 0) exit() s = og_s while s > 0: for i in range(9, 0, -1): if s - i >= 0: s -= i maxn += str(i) break if maxn == "" or len(maxn) > m: print(-1, -1) exit() num_zeroes = m -...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR IF VAR STRING FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys ms = input() m, s = map(int, ms.split()) if s == 0 and m != 1 or s > m * 9: print("-1 -1") sys.exit(0) sum = s for i in range(m): x = max(sum - (m - 1 - i) * 9, 0) if x == 0 and i == 0 and m != 1: x = 1 print(x, end="") sum -= x print(" ", end="") sum = s for i in range(m): ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
ls = input().split(" ") l = int(ls[0]) n = int(ls[1]) if n < 0 or n > l * 9: print("-1 -1") elif n == 0: if l == 1: print("0 0") else: print("-1 -1") else: m = "" n1 = n while n >= 9: m += "9" n -= 9 if len(m) != l: m += "%d" % n while len(m) != l:...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER VAR STRING VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 1: print("1" + "0" * (m - 1), "1" + "0" * (m - 1)) exit() if s == 0 and m == 1: print("0 0") exit() if s == 0 or s > 9 * m: print("-1 -1") exit() dev = s // 9 s -= dev * 9 if dev == m: print("9" * dev, "9" * dev) exit() if dev + 1 == m: if s =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CAL...