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...
m, s = map(int, input().split()) maximum = "" minimum = "" if s == 0: if m == 1: print("0 0\n") else: print("-1 -1\n") exit() temp = "9" * (s // 9) if s % 9: temp += f"{s % 9}" if len(temp) > m: print("-1 -1\n") exit() while len(temp) < m: temp += "0" maximum = temp temp = te...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR 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...
def small_below(m, s): if m == 1: return s else: num = "1" for i in range(m - 2): num += "0" num += str(s - 1) return num def big_below(m, s): num = str(s) for i in range(m - 1): num += "0" return num def small(m, s): num = "" g...
FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN 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...
m, s = [int(x) for x in input().split(" ")] if s < 1 and m > 1 or s > 9 * m: print("-1 -1") else: maxl = [(9) for i in range(m)] smxl = 9 * m diff = smxl - s i = -1 while diff != 0: sub = min(diff, 9) maxl[i] -= sub diff -= sub i -= 1 minl = [1] + [(0) for i i...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR 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...
def minim(a, b): if a < b: return a else: return b m, s = input().split() m = int(m) s = int(s) maxi = [] mini = [] mini.append(1) for i in range(0, m - 1): mini.append(0) for i in range(0, m): maxi.append(9) sum = 9 * m if s > sum: print("-1 -1") elif s == sum: for i in range(...
FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR 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...
def Main(): m, s = map(int, input().split()) nnines = s // 9 remd = s % 9 ans1 = "" ans2 = "" if s == 0: if m > 1: print("-1 -1") else: print("0 0") elif m * 9 < s: print("-1 -1") elif nnines == m: ans1 += "9" * m print(ans1...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR VAR 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...
import sys m, s = map(int, input().split()) lmin = ["0" for x in range(m)] lmax = ["0" for x in range(m)] if m == 1: if s > 9 * m: print("-1 -1") sys.exit() else: print(str(s) + " " + str(s)) sys.exit() elif s == 0 or s > 9 * m: print("-1 -1") sys.exit() elif s <= 9: ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR EXPR 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...
X = 101 Y = 901 def pr(dp): for i in dp: print(*i) def getMax(): dp = [[(0) for i in range(Y)] for j in range(X)] for i in range(10): dp[1][i] = i for i in range(2, X): for j in range(1, Y): if j > 9 * i: break if dp[i - 1][j] != 0: ...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP NUMBER VAR IF VAR BIN_OP 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 = tuple(map(int, input().split())) l = [] q = [] s1 = s ans = 0 if s > m * 9: print("-1 -1") elif s == 0 and m == 1: print("0" * m + " " + "0" * m) else: for i in range(m): q.append(0) if s == 0: ans = 1 break if i == m - 1: s -= 1 ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR STRING BIN_OP STRING VAR FOR VAR FUNC_CALL VAR VAR EXPR 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()) if not m == 1 and s == 0: print(-1, -1) elif s > 9 * m: print(-1, -1) elif m == 1: print(s, s) elif s == 9 * m: te = "" for i in range(m): te = te + "9" print(te, te) elif s > 9 * (m - 1) and s < 9 * m: max = "" min = str(s % 9) for i in range...
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 EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING EXPR FUN...
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...
o = input().rstrip().split(" ") a = int(o[0]) b = int(o[1]) N = a M = b if a == 1 and b > 9: print(-1, -1) elif b == 0: if a == 1: print(0, 0) else: print(-1, -1) elif a * 9 < b: print(-1, -1) else: b -= 1 A = b // 9 B = b - A * 9 L = [] if 1: for i in range(0...
ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF 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...
def find_min_max(length, summ): length = int(length) summ = int(summ) if summ == 0 and length != 1: print("-1 -1") return if summ == 0 and length == 1: print("0 0") return max = [(0) for x in range(length)] count = summ // 9 if count == length and summ % 9: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN 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...
n, s = map(int, input().split(" ")) if n == 1 and s == 0: print(0, 0) elif s < 1 or s > 9 * n: print(-1, -1) else: arr = [0] * n arr1 = [0] * n s1 = s i = 0 while s > 9: arr[i] = 9 s -= 9 i += 1 arr[i] = s if arr[-1] == 0: arr1[0] = 1 flag = 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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 LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE 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 = list(map(int, input().split())) m = a[0] s = a[1] if s == 0: if m == 1: print(0, 0) else: print(-1, -1) else: k = s // 9 if k > m or k == m and k * 9 < s: print(-1, -1) elif k == m: print("9" * m, "9" * m) elif k == m - 1: if k * 9 == s: pr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR 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 sumof(x): if x == 0: return 0 return x % 10 + sumof(int(x / 10)) def po(a, b): ans = 1 for x in range(b): ans = ans * a return ans numbers = list(map(int, input().split())) m = numbers[0] n = numbers[1] maxdig = int(n / 9) maxi = -1 mini = -1 if n > 9 * m: print("-1 -1") ...
FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSI...
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 = "" def large(s, n): s1 = "" k = s while k > 9: k -= 9 s1 += str(9) s1 += str(k) for i in range(n - len(s1)): s1 += "0" return s1 if (s != 0 or n == 1) and s <= 9 * n: s1 = large(s, n) s2 = "" kk = n ss = s if (...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING RETURN VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR 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, m = map(int, input().split()) if m > n * 9 or n > 1 and m == 0: print(-1, -1) elif n == 1 and m == 0: print(0, 0) else: a, g = "", m - 1 for i in range(n): if m > 9: a += "9" m -= 9 else: a += str(m) m = 0 r = [a] a = "" for ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR A...
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 or s > 9 * m: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: s -= 1 num = [0] * m num[0] = 1 n = s for i in range(m - 1, -1, -1): if n + num[i] >= 9: n -= 9 - num[i] num[i] = 9 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER 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 = list(map(int, input().split())) flag = True large = 0 small = 0 m1 = m - 1 m2 = 0 s1 = s if s == 0 and m == 1: small, large = 0, 0 flag = False elif s > 9 * m or s < 1: flag = False large = -1 small = -1 if flag: while s1 != 0: if s1 > 9: large += 9 * 10**m1 ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER 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...
digit_sum = lambda number_str: sum(int(x) for x in number_str if x.isdigit()) def main(): m, s = input().split() try: m = int(m) s = int(s) except TypeError: print("Invalid not number input") if m == 1 and s == 0: print("0 0") return if not 1 <= s <= 9 * m: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR 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...
def check(m, s): return s <= m * 9 and s >= 0 m, s = [int(i) for i in input().split()] if m * 9 < s or s < 1 and m > 1: print(-1, -1) else: tmp = s for i in range(m): for j in range(10): if (i > 0 or j > 0 or m == 1 and j == 0) and check(m - i - 1, tmp - j): print(j...
FUNC_DEF RETURN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER 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...
A = list(map(int, input().split())) n, m = A if n == 1 and m == 0: print("0 0") elif not 1 <= m <= 9 * n: print("-1 -1") else: largest = "" SUM = 0 for x in range(n): if SUM + 9 > m: largest += str((m - SUM) % 9) SUM += (m - SUM) % 9 else: largest ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP BIN_OP 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...
m, s = [int(x) for x in input().split()] if s == 0 and m != 1 or s / 9 > m: print("-1 -1") else: tm = m ts = s mn = "" while m > 0: if m == 1: mn = str(s) + mn else: mn = str(min(9, s - 1)) + mn s -= min(9, s - 1) m -= 1 m = tm s = ...
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 ASSIGN VAR VAR ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER 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...
n, m = map(int, input().split()) a = [(0) for _ in range(n)] b = [(0) for _ in range(n)] a[0] = 1 s = m - 1 for i in range(n): if s >= 9: a[n - i - 1] += 9 s -= 9 else: a[n - i - 1] += s s = 0 a = [str(i) for i in a] if s != 0 or any(int(i) < 0 or int(i) > 9 for i in a): prin...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR A...
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 s < 1 and m > 1 or s > 9 * m: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: n = s // 9 l = s - 9 * n mi = 0 ma0 = [str(9)] * n if l != 0: ma0.append(str(l)) for i in range(m - n - 1): ma0.append(str(0)) e...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL 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 = [int(x) for x in input().split(" ")] if m > 1 and s == 0 or 9 * m < s: print(-1, -1) exit() if m == 1 and s == 0: print(0, 0) exit() t = s big = 0 for i in range(m - 1, -1, -1): z = min(t, 9) big += 10**i * z t -= z t = s small = 0 for i in range(0, m): z = min(t, 9) small += ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR 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...
import sys a = sys.stdin.readline() a = a.split(" ") m = int(a[0]) s = int(a[1]) if s > 9 * m or s == 0 and m > 1: print("-1 -1") elif m == 1: print(s, "", s) else: Big = [(0) for x in range(m)] p = 0 while s > 9: s -= 9 Big[p] = 9 p += 1 Big[p] = s Smal = [(0) for x...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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...
m, s = map(int, input().split()) if s > 9 * m: print("-1 -1") elif s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: a = s // 9 b = s % 9 d = int(10 ** (m - a) * (10**a - 1)) + int(b * 10 ** (m - a - 1)) if a + 1 < m: if b != 0: c = 10 ** (m - 1)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP 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 = map(int, input().split()) mi = [0] * m ma = [0] * m mi[0] = 1 k = s - 1 if s == 0 and m == 1: print(0, 0) elif (s > 9 * m or s < 1) and m >= 1: print(-1, -1) else: for i in range(m): r = min(9, k) k -= r mi[m - i - 1] += r k = s for i in range(m): r = min(9, k)...
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 NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR...
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, k = map(int, input().split(" ")) if k == 0 and m == 1: print(0, 0) elif k == 0 or k > 9 * m: print(-1, -1) else: s = k maximum = [0] * m minimum = [0] * m i = 0 while i < m and s > 0: if s <= 9: maximum[i] += s s = 0 else: maximum[i] += ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF ...
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, p = [int(j) for j in input().split()] s = p min = ["1"] + list("0" * (m - 1)) max = ["1"] + list("0" * (m - 1)) if m == 1 and p == 0: print(0, 0) exit() if s < 1 or s > 9 * m: print(-1, -1) exit() s -= 1 p -= 1 for i in range(m - 1, 0, -1): if s > 9: min[i] = str(int(min[i]) + 9) else...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR BIN_OP STRING BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR 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...
n, m = list(map(int, input().split())) if m > n * 9 or m == 0 and n != 1: print("-1 -1") elif n == 1 and m == 0: print("0 0") elif n == 1 and m == 1: print("1 1") else: temp = m i = 0 mi = ma = "" if m - 1 > 9 * (n - 1): mi += str(m - 9 * (n - 1)) m = 9 * (n - 1) mi +...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR STRING IF BIN_OP 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 = input().split() m = int(n[0]) s = int(n[1]) l = m k = s min = "" max = "" x = [] x2 = [] y = [] if 9 * m >= s >= 1: if 9 * m > s > (m - 1) * 9: x.append(s - 9 * (s // 9)) s = 9 * (s // 9) m = m - 1 elif s == 9 * m: x.append(9) s = s - 9 m = m - 1 elif s ==...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST IF BIN_OP NUMBER VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER 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 = list(int(a) for a in input().split()) if s == 0: if m == 1: print(0, 0) else: print(-1, -1) elif m * 9 < s: print(-1, -1) else: st = 10 ** (m - 1) ts = s - 1 i = 0 while ts >= 9: st += 9 * 10**i ts -= 9 i += 1 if ts > 0: st += (s - 1...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR 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 BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHI...
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 answer(m, s): if s == 0: if m == 1: return [0, 0] else: return [-1, -1] max_s = 9 * m if s > max_s: return [-1, -1] if s == max_s: return [int("9" * m), int("9" * m)] n9 = s // 9 rest = s % 9 if rest == 0: n9 -= 1 re...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN LIST NUMBER NUMBER RETURN LIST NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR RETURN LIST NUMBER NUMBER IF VAR VAR RETURN LIST FUNC_CALL VAR BIN_OP STRING VAR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER 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...
n, m = [int(i) for i in input().split()] c = m // 9 d = m % 9 k = n * [0] if m <= 9 and n == 1: print(m, m) if m <= 9 and n > 1: if m == 1: k[0] = 1 k = list(map(str, k)) print("".join(k), "".join(k)) elif m == 0: print(-1, -1) else: u = k u[0] = 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR 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...
m, s = [int(x) for x in input().split()] def solvemin(arr, index, currsum): if index == 0: for i in reversed(range(1, 10)): if currsum + i - 1 == s: arr[index] = i return True else: return False for i in reversed(range(1, 10)): if...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR RETURN 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...
def solver(m, s): if m == 1 and s == 0: return 0, 0 if m == 0: return -1, -1 if m > 1 and s == 0: return -1, -1 if s > m * 9: return -1, -1 res = "" for i in range(m): if s == 0: res += "0" else: x = min(9, s) re...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR 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...
rin = lambda: map(int, input().split()) m, s = rin() a, b = m * [0], m * [0] a[0] = b[0] = 1 if m > 1 and s == 0: print("-1 -1") elif m == 1 and s == 0: print("0 0") else: temp = s - 1 pos = m - 1 while temp > 0 and pos >= 0: a[pos] += 9 if temp > 9 else temp temp -= a[pos] p...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR LIST NUMBER BIN_OP VAR LIST NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP 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...
l = list(map(int, input().split())) def solve(m, s): min_int, max_int = -1, -1 if s > 9 * m or s < 1 and m > 1: print(min_int, max_int) else: result = 0 tmp = s for _ in range(m): result = result * 10 + min(9, tmp) tmp -= min(9, tmp) max_int ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER VAR 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 * 9 < s or s == 0 and m > 1: print("-1 -1") exit() if s == 0 and m == 1: print("0 0") exit() mn = "" ss = s - 1 for i in range(m - 1): x = min(ss, 9) ss -= x mn = chr(ord("0") + x) + mn ss += 1 mn = chr(ord("0") + ss) + mn mx = "" ss = s for i in range(m...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUN...
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): a = b = [] if s == 0: if m == 1: a = b = ["0"] else: a = b = ["-1"] return a, b if s > 9 * m: a = b = ["-1"] return a, b s_a = s_b = s s_b -= 1 for i in range(m - 1): if s_b >= 9: a = a + ["9"] ...
FUNC_DEF ASSIGN VAR VAR LIST IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR LIST STRING ASSIGN VAR VAR LIST STRING RETURN VAR VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR VAR LIST STRING RETURN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR LIST STRING 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()) if s <= 0 or s > 9 * m: if s == 0 and m == 1: print(0, 0) else: print(-1, -1) else: min_n = "" arr = [0] * m arr[-1] = 1 k = s - 1 for i in range(m): arr[i] = min(9, k) k -= arr[i] min_n += str(arr[i]) min_n = min_n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSI...
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()) dp, dp2 = [], [] if s > m * 9 or s == 0 and m > 1: print("-1 -1") elif m == 1 and s == 0: print("0 0") elif s == 1: dp.append("1") for i in range(m - 1): dp.append("0") dp2 = dp elif s > 1 and s < 10 and m != 1: dp.append(str(s)) for i in range(m - 1)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING 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...
import sys inp = sys.stdin.readline()[:-1].split(" ") m = int(inp[0]) s = int(inp[1]) copyM = m copyS = s ans = "" mx = "" mn = "" if s > 0 and m * 9 >= s: for i in range(m, 0, -1): if s <= 0: digit = 0 else: digit = 9 if digit > s: digit = s ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF 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...
S = list(map(int, input().split())) m = S[0] s = S[1] s2 = S[1] st = "-1 -1" if m == 1: if s > 9: print(st) else: print(str(s) + " " + str(s)) elif s == 0: print(st) elif s > 9 * m: print(st) else: dp = [(0) for i in range(m)] for i in range(m): allowed = None if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF 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, t] = list(map(int, input().split(" "))) m = l n = t large = [] small = [] if t == 0 and l > 1: print("-1 -1") elif 9 * l < t: print("-1 -1") elif l == 1 and t == 0: print("0 0") else: while l > 0 and t > 9: large += ["9"] t -= 9 l -= 1 large += [t] + (l - 1) * ["0"] w...
ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER 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 = [int(x) for x in input().split()] def can(m, s): return s >= 0 and s <= 9 * m res1 = [] sumi = s for i in range(0, m): for j in range(0, 10): if (i > 0 or j > 0 or m == 1 and j == 0) and can(m - i - 1, sumi - j): res1.append(j) sumi -= j break if s == 0 and...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR 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...
def findLargest(m, s): if (s + 8) // 9 > m or s == 0 and m >= 2: largest = "-1" elif m > s // 9: largest = "9" * (s // 9) + str(s % 9) + "0" * (m - s // 9 - 1) else: largest = "9" * (s // 9) return largest m, s = input().split() m, s = int(m), int(s) largest = findLargest(m, s)...
FUNC_DEF IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER RETURN 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...
m, s = list(map(int, str.split(input()))) if s == 0 and m == 1: print(0, 0) elif s == 0 or s > 9 * m: print(-1, -1) else: num = [0] * (m - 1) + [1] for i in range(m): num[i] += min(9, s - sum(num)) a = str.join("", list(map(str, num[::-1]))) num = [0] * m for i in range(m): n...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR VAR VAR 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...
a, b = [int(i) for i in input().split()] if a == 1 and b < 10: print("%d %d" % (b, b)) elif b == 0: print("-1 -1") elif b > 9 * a: print("-1 -1") else: x = int(b / 9) y = b % 9 if a == x + 1 and y != 0: print(str(y) + "9" * x, "9" * x + str(y)) elif x == a and y == 0: print("...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER 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...
from sys import stdin, stdout input = stdin.readline m, s = map(int, input().split()) if s == 0 and m == 1: stdout.write("0 0") exit(0) elif s == 0: stdout.write("-1 -1") exit(0) ma = ["9"] * (s // 9) ma += [str(s % 9)] if s % 9 != 0 else [] while len(ma) < m: ma.append("0") mi = list(reversed(ma.c...
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER LIST FUNC_CALL VAR 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 = map(int, input().split()) if m == 1 and s == 0: print("0 0") elif s < 1 or s > m * 9: print("-1 -1") else: a = [0] * m b = [0] * m for i in range(m - 1): if i == 0: for j in range(1, 10): if s - (sum(a) + j) <= (m - i - 1) * 9: a[i] = j ...
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 VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER 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...
m, S = map(int, input().split()) def valid(m, s): return 9 * m + s >= S def rtol(): l = [0] * m l[0] = 1 s = 1 if s == S: return l for i in range(m): while l[i] < 9: l[i] += 1 s += 1 if S == s: return l if not va...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP NUMBER VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN VAR IF FUNC_CAL...
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().strip().split()) def maxf(s, n): if 9 * n < s: return -1 if s == 0 and n == 1: return 0 if s == 0 and n > 1: return -1 if s <= 9: return str(s) + "0" * (n - 1) return "9" + maxf(s - 9, n - 1) m = maxf(s, n) def minf(s, n): if m == -1:...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP NUMBER VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER RETURN BIN_OP STRING 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...
m, s = map(int, input().split()) def check_val(m, s): return s <= 9 * m def max_num(m, s): number = [(0) for i in range(m + 1)] for i in range(m): if s >= 9: number[i] = 9 s = s - 9 else: number[i] = s s = 0 return "".join(map(str, numb...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER RETURN FUNC_CALL 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...
m, s = map(int, input().split()) if s == 0 and m == 1: print(0, 0) else: lsts, lstl = [1] + (m - 1) * [0], [1] + (m - 1) * [0] s -= 1 t = s for i in range(m - 1, -1, -1): if s >= 9 - lsts[i]: k = lsts[i] lsts[i] = 9 s -= 9 - k elif s >= 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR 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...
def maxNum(l, s): if l == 1: return s elif s < 10: return s * 10 ** (l - 1) else: return 9 * 10 ** (l - 1) + maxNum(l - 1, s - 9) def minNum(l, s): if l == 1: return s if s == 1: return minNum(l - 1, 1) * 10 if s < 10: return s - 1 + minNum(l - 1...
FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER 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()) if m == 1 and s == 0: print(0, 0) exit() if not 1 <= s <= 9 * m: print(-1, -1) exit() s_copy = s ans1 = "" for i in range(m): left = m - i - 1 max_rem = s - left * 9 if max_rem <= 0: if i == 0: ans1 += "1" s -= 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 EXPR FUNC_CALL VAR IF NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR 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...
m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) elif s == 0: print(-1, -1) elif s < 1 or s > 9 * m: print(-1, -1) else: a = [1] + [0] * (m - 1) s1 = s - 1 i = m - 1 while s1 > 9: a[i] = 9 s1 -= 9 i -= 1 a[i] += s1 b = [0] * m i = 0 w...
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 EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER 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...
def Legkisebb(curr, su): tes = list(str(curr)) while su > 0: for i in range(len(tes)): if tes[i] != "9": temp = int(tes[i]) temp = temp + 1 tes[i] = str(temp) su = su - 1 break return int("".join(tes)) def ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_DEF ASSIGN 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...
x = input().split() x[0] = int(x[0]) x[1] = int(x[1]) if x[0] * 9 < x[1] or x[0] > 1 and x[1] == 0: print(-1, -1) else: a = int(x[1] / 9) b = x[1] - 9 * a if a == x[0]: for i in range(x[0]): print(9, end="") elif b == 0 and a != 0: print(1, end="") t = 2 w...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP 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, s = map(int, input().split()) if s == 0 and n == 1: print(0, 0) elif s < 1 or s > 9 * n: print(-1, -1) else: ans1 = 10 ** (n - 1) s1 = s - 1 k = 1 while s1 > 0: ans1 += min(s1, 9) * k s1 -= min(s1, 9) k *= 10 ans2 = "" while s > 0: ans2 += str(min(9, 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 NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP 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 = [int(x) for x in input().split()] def getMaxVal(m, s): if s == 0 and m == 1: return "0" if s == 0 or s > 9 * m: return "-1" q = int(s / 9) r = s - q * 9 if r: return "9" * q + str(r) + "0" * (m - q - 1) else: return "9" * q + "0" * (m - q) def getMinVal...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR RETURN BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR 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...
a, b = input().split() a = int(a) b = int(b) c = b - 1 n = 10 ** (a - 1) m = 0 if b < 0 or b > 9 * a: print("-1 -1") elif a == 1 and b == 0: print("0 0") elif b == 0 and a > 1: print("-1 -1") else: for i in range(a): if b >= 9: m += 9 * 10 ** (a - 1 - i) if 0 < b < 9: ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER 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()) t = {} if m == 1 and s <= 9 and s >= 0: print(str(s) + " " + str(s)) if m != 1 and s == 0 or s > m * 9: print("-1 -1") if m > 1 and s >= 1 and s < m * 9: nmax = "" c9 = s // 9 y9 = s % 9 if c9 >= 1: nmax += "9" * c9 nmax += str(y9) nmax +=...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR STRI...
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()) flag = False smallest = [] longest = [] i, p = n, s while i > 0: if p == 0: longest.append("0") else: longest.append(str(min(p, 9))) p -= int(longest[len(longest) - 1]) i -= 1 if n > 1 and s == 0: flag = True if p > 0: flag = True i, p = n, s ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF 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...
length_of_integer, sum_of_digits = map(int, input().split()) if ( sum_of_digits > length_of_integer * 9 or sum_of_digits == 0 and length_of_integer > 1 ): print(-1, -1) elif sum_of_digits == 0 and length_of_integer == 1: print(0, 0) else: ans = [(0) for i in range(length_of_integer - 1)] ans...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR 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 = map(int, input().split()) if 9 * m < s: print(-1, -1) elif m >= 2 and s == 0: print(-1, -1) elif m == 1 and s == 0: print(0, 0) else: mi = "" s1 = s - 1 while s1 > 0: if s1 <= 9: mi += str(s1) s1 = 0 else: mi += "9" s1 -= 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER 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 m == 1 and s == 0: print("0 0") elif s < 1 or s > 9 * m: print("-1 -1") else: d = {} for i in range(9, -1, -1): d[i] = s // i s = s % i if s == 0: break big = "" for i in d: if d[i] == 0: continue ...
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 VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR STRING FOR...
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 tn(n): if n: return tn(n // 10) + 1 return 0 n, k = map(int, input().split()) if k > n * 9 or k == 0 and n > 1: print(-1, -1) else: s = "" d = [] f = k while f - 9 > 0: f -= 9 s = "9" + s s += str(f) s += (n - len(s)) * "0" d = s[::-1] if d[0] ==...
FUNC_DEF IF VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER 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...
def can(m, s): return s >= 0 and s <= 9 * m m, s = map(int, input().split()) z = s l = z minimize = [] for i in range(m): if i == 0: for j in range(1, 10): if can(m - 1, s - j): minimize.append(str(j)) s -= j break elif i == m - 1: ...
FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR 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...
info = input() info = info.split() m = int(info[0]) s = int(info[1]) if 9 * m < s: print("-1 -1") elif s == 0: if m == 1: print("0 0") else: print("-1 -1") elif s == 1: print("{} {}".format(10 ** (m - 1), 10 ** (m - 1))) else: maxr = 0 minr = 0 Lmax = [] Lmax.append(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 BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING BIN_OP NUMBER 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()) mx = "" mn = "" if s < 1 and m > 1 or s > m * 9: print("-1 -1") else: k = s for i in range(m - 1, -1, -1): j = max(0, k - 9 * i) if j == 0 and i == m - 1 and k: j = 1 mx += str(j) k -= j print(mx) k = s for i in range(m...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER 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...
m, s = map(int, input().split()) if s == 0: if m == 1: print(0, 0) else: print(-1, -1) elif m * 9 < s: print(-1, -1) else: max_ = [0] * m min_ = [0] * m i = 0 while sum(max_) < s: chng = min(9, s - sum(max_)) max_[i] = chng i += 1 i = -1 min_[0...
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 IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR 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...
line = input().split() n = [int(i) for i in line] if n[1] == 0 and n[0] != 1: print("-1 -1") elif n[1] > 9 * n[0]: print("-1 -1") elif n[1] == 9 * n[0]: print("9" * n[0] + " " + "9" * n[0]) elif int(n[1] / 9) + 1 == n[0]: b = "9" * (n[0] - 1) + str(n[1] % 9) a = str(n[1] % 9) + "9" * (n[0] - 1) ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR NUMBER STRING 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...
l = list(map(int, input().split())) if l[1] == 0 and l[0] > 1 or 9 * l[0] < l[1]: print("-1 -1") elif l[1] == 0 and l[0] == 1: print("0 0") else: rmax = l[1] // 9 * "9" if l[1] % 9 != 0: rmax += str(l[1] - 9 * (l[1] // 9)) + (l[0] - 1 - l[1] // 9) * "0" if l[0] - 1 - l[1] // 9 > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING IF BIN_OP VAR NUMBER NUMBER 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...
import sys def valid_capacity(num_digits, sum_digits): return 0 <= sum_digits <= 9 * num_digits def lead_zero(i, digit): return i == 0 and digit == 0 def solve_scouter(num_digits, sum_digits): if num_digits > 1 and sum_digits == 0: print("-1 -1") return if num_digits == 1 and sum_d...
IMPORT FUNC_DEF RETURN NUMBER VAR BIN_OP NUMBER VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF 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...
m, s = (int(x) for x in input().split(" ")) max = -1 min = -1 if s > 0: new_s = s - 1 min = 10 ** (m - 1) for i in range(m - 1): if new_s > 9: new_s -= 9 min += 10**i * 9 else: min += 10**i * new_s new_s = 0 if new_s > 0: if new_s <...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP 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()) a = "" b = "" if m == 1 and s == 0: print("0 0") elif m > 1 and s == 0: print("-1 -1") else: for i in range(m): a += str(min(9, s)) s -= min(9, s) if s != 0: print("-1 -1") else: b = a[::-1] if b[0] == "0": b = "1" ...
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 FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CAL...
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 can(i, m, s): if i == 0 and s == 0 and m > 1: return False if s >= 0 and s <= 9 * m: return True return False m, s = map(int, input().split()) if can(0, m, s): su = s out = "" for i in range(m): for d in range(0, 10): if (i > 0 or d > 0 or m == 1 and s =...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER 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...
l, s = map(int, input().split()) m = l if s == 0 and m > 1: print("-1 -1") elif s > 9 * m: print("-1 -1") elif m == 1: if s <= 9: print(str(s), str(s)) else: print("-1 -1") else: list1 = [] while s >= 9 and m >= 0: list1.append("9") s -= 9 m -= 1 if m ...
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 BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST WHILE 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 f(a, b): if b == 1: return str(b) + "0" * (a - 1) if a == 1: return str(b) c = min(b - 1, 9) return f(a - 1, b - c) + str(c) def g(a, b): if b < 10: return str(b) + "0" * (a - 1) else: return "9" + g(a - 1, b - 9) a = list(map(int, input().split())) if a =...
FUNC_DEF IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP 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...
a = list(map(int, input().split())) summ = a[1] leng = a[0] if leng == 1 and summ == 0: print("0 0") exit() if summ == 0 or leng * 9 < summ: print("-1 -1") exit() maximum = "" tmp = summ for i in range(9, 0, -1): if a[1] / i > 0: maximum += str(i) * int(tmp / i) tmp -= int(tmp / i) *...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR FOR 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 = input().split() m = int(m) s = int(s) s2 = s min = "" max = "" if m > 1 and s == 0 or s > 9 * m: print("-1 -1") else: while s >= 9: max += "9" s -= 9 if s != 0: max += str(s) max += "0" * (m - len(max)) while s2 > 9: min += "9" s2 -= 9 if m - len(mi...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR 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...
jiweishu, he = [int(i) for i in input().split()] zuida1 = 9 * jiweishu zuixiao1 = 1 if he == 0 and jiweishu == 1: print("0 0") exit() if he > zuida1 or he < zuixiao1: print("-1 -1") exit() if jiweishu == 1: print(he, end=" ") print(he) exit() if he == 0 and jiweishu != 1: print("-1 -1") ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_C...
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 find_max_num(s, m): if s == 0 and m != 1 or s > m * 9: return "-1" else: return find_max_num_aux(s, m) def find_max_num_aux(s, m): if s < 0: return "-1" if m == 1: return str(s) else: for i in range(9, -1, -1): x = find_max_num_aux(s - i, m -...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER RETURN STRING RETURN FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN STRING IF VAR NUMBER RETURN FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FU...
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 getMax(length, sm): if length == 1 and sm == 0: return "0" elif length == 0 or sm == 0: return "-1" result = "" for i in range(0, length): add = min(sm, 9) result += str(add) sm -= add if sm > 0: return "-1" return result def getMin(length, s...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER RETURN STRING RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETU...
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()] maxnum = ["0"] * m minrev = ["0"] * m sumnum = s tfmax = 0 tfmin = 0 for i in range(m): if i < m - 1: if sumnum >= 9: maxnum[i] = "9" sumnum -= 9 else: maxnum[i] = str(sumnum) sumnum -= sumnum if i == m - 1:...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR I...
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 = list(map(int, input().split())) n = m[0] s = m[1] if 9 * n < s or n > 1 and s == 0: print("-1 -1") exit() num = [] while s > 0: if s <= 9: num.append(str(s)) s = 0 else: num.append(str(9)) s = s - 9 while len(num) != n: num.append(str(0)) s1 = num[::-1] if n > 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN 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, t = map(int, input().split()) big = [0] * m small = [0] * m s = t if s == 0 and m > 1 or s > 9 * m: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: if s <= 9: big[0] = s else: i = 0 while s > 9: big[i] = 9 s = s - 9 i = i + 1 ...
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 NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER WH...
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 fmax(m, s, number_max): for i in range(m): for y in range(9, 0, -1): if s // y > 0: s -= y number_max[i] = str(y) break return "".join([str(x) for x in number_max]) def fmin(m, s, number_min): for i in range(m - 1, -1, -1): fo...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR 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()) if s > m * 9 or s == 0 and m != 1: print(-1, -1) else: a = [0] * m i = m - 1 ss = s while ss > 9: a[i] = 9 ss -= 9 i -= 1 if i == 0: a[0] = ss else: a[i] = ss - 1 a[0] = 1 b = [0] * m ss = s i = 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR 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...
__author__ = "1" def minimize(m, s): if m == 1 and s == 0: return 0 if s == 0: return -1 array = [(0) for i in range(m)] array[0] = 1 currentFiller = m - 1 val = s - 1 for i in range(s - 1): if array[currentFiller] < 9: array[currentFiller] += 1 ...
ASSIGN VAR STRING FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER 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...
m, s = map(int, input().split()) f = [[(0) for i in range(0, 1005)] for i in range(0, 2005)] for i in range(0, m + 10): for j in range(0, s + 10): f[i][j] = -1 def dp(pos, sum): if sum > s: return 0 if pos == m: return sum == s if f[pos][sum] != -1: tam = f[pos][sum] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN VAR VAR I...
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) a = s x = 0 y = 0 n = 0 if s == 0: if m == 1: x = 0 y = 0 else: x = -1 y = -1 elif s > 9 * m: x = -1 y = -1 else: while s > 0: if s > 9: y += 9 * 10**n s -= 9 elif s == 1: ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN 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 = map(int, input().split()) k = [] if s == 0 and m != 1: print(-1, end=" ") print(-1) elif s == 0 and m == 1: print(0, end=" ") print(0) elif s > 9 * m: print(-1, end=" ") print(-1) else: a = s - 1 for i in range(m): if a > 9: k.append(9) a = a - 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL 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...
a, b = (int(x) for x in input().split(" ")) if a > 1 and b == 0 or b > 9 * a: print("-1 -1") elif a == 1 and b == 0: print("0 0") else: c = a * [0] m = b for i in range(a): if m > 9: c[i] = 9 m -= 9 else: c[i] = m break da = "".join...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER 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...
ms = [int(i) for i in input().split()] if ms[1] == 0: if ms[0] == 1: print("0 0") else: print("-1 -1") elif ms[0] * 9 < ms[1]: print("-1 -1") elif ms[0] == 1: print(ms[1], ms[1]) else: num = [] for i in range(ms[1] // 9): num.append(9) if ms[1] % 9 != 0: num.a...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR 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...
from sys import stdin def find_largest(m, s): arr = [9] * m for i in range(m - 1, -1, -1): arr[i] = 0 if sum(arr) > s: continue else: j = i while sum(arr) != s: arr[j] += 1 if arr[j] == 10: return [...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER RETURN LIST NUMBER RETURN VAR RETURN LIST NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR 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...
def solve(m, left): s = left if s == 0 and m >= 2 or s > 9 * m: print(-1, -1) return if m == 1: print(s, s) return cnt = 9 ans = [] for i in range(m, 0, -1): if s // 9 != 0: ans.append(cnt) s -= cnt else: cnt = s...
FUNC_DEF ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER...