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...
n, s = map(int, input().split()) def get_max(n, s): s_nine = s // 9 s_r = s % 9 if s_r != 0: s_n = "9" * s_nine + str(s_r) else: s_n = "9" * s_nine s_l = n - len(s_n) return s_n + "0" * s_l def get_min(n, s): s_nine = (s - 1) // 9 s_r = (s - 1) % 9 s_n = "9" * s_n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR BIN_OP STRING VAR FUNC_DEF 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()) sr = "" if s == 0 and m > 1: print("-1 -1") exit() if s == 0 and m == 1: print("0 0") exit() while s >= 9: s -= 9 sr += "9" if s == 8: s -= 8 sr += "8" if s == 7: s -= 7 sr += "7" if s == 6: s -= 6 sr += "6" if s == 5: s -= 5 sr +=...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF 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 WHILE VAR NUMBER VAR NUMBER VAR STRING IF VAR NUMBER VAR NUMBER VAR STRING IF VAR NUMBER VAR NUMBER VAR S...
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()) temp = s large = [] i = 0 while i < m: if s > 9: s -= 9 large.append("9") else: large.append(str(s)) s -= s i += 1 large = "".join(large) if large[0] == "0" and m > 1 or s > 0: large = -1 small = [] i = m - 1 s = temp while i > 0: if s...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF VAR NUMBER STRING VAR NUMBER 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...
import sys n, s = map(int, input().split()) max_n = [0] * n min_n = [0] * n min_n[0] = 1 if s is 0 and n > 1: print(-1, -1) sys.exit(0) if s is 0 and n is 1: print(0, 0) sys.exit(0) if s > 9 * n: print(-1, -1) sys.exit(0) s1 = s - 1 for i in range(n): if s >= 9: max_n[i] = 9 ...
IMPORT 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 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 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()) maxi = "" mini = "" if s == 0: if m == 1: print("0 0") else: print("-1 -1") else: for i in range(m): k = min(9, s) maxi += str(k) s -= k if s > 0: print("-1 -1") else: mini = maxi[::-1] while mini[0] == ...
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING 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...
x, y = map(int, input().split()) def big(x, y): if y >= 9 and y <= x * 9: a = [9] * (y // 9) c1 = y - sum(a) if c1 != 0: a.append(c1) if len(a) != x: a1 = [0] * (x - len(a)) a = a + a1 return "".join(str(i) for i in a) elif 0 < y < 9:...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR FUNC_CALL 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...
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def sumofdigits(n): return sum([int(i) for i in str(...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL 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...
def func(): tokens = input().split() length = int(tokens[0]) sum = int(tokens[1]) sum1 = sum if sum == 0 and length == 1: print("0 0") return start = [] for i in range(length): start.append(0) sum = sum - 1 digit = len(start) - 1 while 1: if digit ...
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 VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL 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...
a, b = [int(i) for i in input().split()] if a * 9 < b or b < 0: print("-1 -1") elif a == 1 and b == 0: print("0", "0") elif a > 1 and b == 0: print("-1 -1") else: da = b // 9 e = b % 9 ma = "" mi = "" if e == 0: da = da - 1 e = 9 i = 0 while i < da: ma = m...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 STRING ASSIGN VAR S...
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 process(cnt, sm): if sm == 0: if cnt == 1: return 0, 0 return -1, -1 if sm > cnt * 9: return -1, -1 revno, smol = [0] * cnt, [0] * cnt t = sm smol[-1] = 1 t -= 1 i = 0 while t > 0: try: if smol[i] + t > 9: smol[i...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER RETURN NUMBER NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER VAR VAR BIN_OP 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 s == 0 and m == 1: print("0 0") exit() if s > 9 * m or s < 1: print("-1 -1") exit() ans = "" for _ in range(0, m): x = min(9, s) ans += str(x) s -= x ans1 = list(ans) ans1.reverse() for x in range(0, m): if ans1[x] != "0": ans1[0] = str(int(ans...
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 IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR 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 = map(int, input().split()) sn = "" ln = "" a = s t = 0 k = s for i in range(1, m): if s >= 10: sn = sn + str(9) ln = str(9) + ln s = s - 9 k = s elif t != 1: sn = str(s - 1) + sn ln = ln + str(k) k = 0 t = 1 s = 1 else: sn...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR 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, s = str(input()).split() m = int(m) s = int(s) if m > 1 and s == 0 or s > 9 * m: print("-1 -1") elif m == 1: print(str(s) + " " + str(s)) else: num_9 = s // 9 miss = s - 9 * num_9 if miss > 0: count = m - num_9 - 1 if num_9 > 0: max_v = "9" * num_9 + str(miss) + "0" * ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER 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...
m, s = [int(i) for i in input().split()] if m == 1 and s <= 9: print(s, s) elif m == 1: print(-1, -1) elif s >= 1 and s <= m * 9: min_val = [0] * m max_val = [0] * m min_val[0] = 1 s_ = s - 1 for i in range(1, m): if s_ <= 0: break else: min_val[m - i]...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP 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...
def check(s, m): if m == 1 and s == 0: return 0, 0 elif s > m * 9 or s == 0: return -1, -1 else: Low = 10 ** (m - 1) for i in range(s - 1): Low += 10 ** (i // 9) High = 0 for i in range(s): High += 10 ** (m - 1 - i // 9) return ...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER BI...
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 == 0: if n == 1: print(0, 0) else: print(-1, -1) else: mx = "" x = m for i in range(n): if x >= 9: mx += "9" x -= 9 else: mx += str(x) x = 0 if x > 0: mx = -1 mi = ""...
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 STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR 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...
from sys import stdin, stdout def main(): def can(m, s): return s >= 0 and s <= 9 * m def f(m, s): _sum = s minn = 0 for i in range(m): for d in range(0, 10): if (i > 0 or d > 0 or m == 1 and d == 0) and can(m - i - 1, _sum - d): ...
FUNC_DEF FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR 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 VAR VAR VAR NUMBER VAR VAR ASSIGN 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...
from sys import stdin, stdout cin = stdin.readline cout = stdout.write mp = lambda: list(map(int, cin().split())) m, s = mp() rem = s % 9 maxi = "9" * (s // 9) if rem > 0: maxi += str(rem) if len(maxi) > m or len(maxi) == 0 and m > 1: cout("-1 -1") exit(0) maxi += "0" * (m - len(maxi)) mini = maxi[::-1] if...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL 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 STRING BIN_OP VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR 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...
m, s = map(int, input().split()) t = s a, b = [], [] if s > 0 and s <= m * 9: for i in range(m): if s - 9 > 0: p = 9 s = s - 9 else: p = s s = 0 a.append(str(p)) max = "".join(a) a.sort() for i in a: b.append(int(i)) if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR LIST LIST IF VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN 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, n = [int(x) for x in input().strip().split()] if n == 0 and m > 1: res = "-1 -1" print(res) elif n == 0 and m == 1: res = "0 0" print(res) else: result = [None for i in range(m)] s_result = [None for i in range(m)] p = n for i in range(m): if n >= 9: result[i] = 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR 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 = map(int, input().split()) strings = [] count = s n = 0 if s == 0 and m > 1 or s > m * 9: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: for i in range(m): strings.append(0) while count > 0: if count >= 9: strings[n] = 9 count -= 9 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR NUMBER IF 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...
m, s = [int(i) for i in input().split()] if s > 9 * m or s == 0 and m > 1: max = min = -1 else: s_max = s_min = s max_lst = [] min_lst = [] while s_max >= 9: max_lst.append("9") s_max -= 9 if s_max > 0: max_lst.append(str(s_max)) max_lst.extend((m - len(max_lst)) * ["...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP 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...
n, m = map(int, input().split()) a = m z = [(0) for i in range(n)] x = [(0) for i in range(n)] if n == 1 and m == 0: print(0, 0) exit() if m == 0: print(-1, -1) exit() if m > n * 9: print(-1, -1) exit() for i in range(n): z[i] += min(9, m) m -= z[i] if m == 0: break m = a for...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR BIN_OP 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()) n = m s1 = s if s == 0 and m > 1 or s > 9 * m: print(-1, -1) else: max = [0] * m min = [0] * m i = 0 while s: if s > 9: max[i] = 9 s -= 9 i += 1 else: max[i] = s s = 0 while s1: i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER 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 NUMBER WHILE VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER 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()) if (s == 0 or s > 9 * m) and not (m == 1 and s == 0): print(-1, -1) elif m == 1 and s == 0: print(0, 0) else: r = s % 9 q = int((s - r) / 9) if q == m: keys = 0 else: keys = 1 ma = [9] * q + [r] * keys + [0] * (m - q - 1) ma = str(ma) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR 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 FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR 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()) if s == 1: res = "1" + "0" * (m - 1) print(res, res) exit(0) arr = [0] * m if 1 > s: if m == 1: print(0, 0) else: print(-1, -1) exit(0) itr = 0 while s > 0 and itr < m: choice = min(9, s) arr[itr] += choice s -= choice itr += 1 if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR IF NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER 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...
m, i_s = map(int, input().split()) min_num = [1] + [0] * (m - 1) s = i_s - 1 for i in range(len(min_num) - 1, -1, -1): val_inc = min(9 - min_num[i], s) min_num[i] += val_inc s -= val_inc if s > 0 or sum(min_num) != i_s or any(map(lambda x: x < 0, min_num)): print(-1, -1) else: max_num = [1] + [0] * ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR VAR VAR VAR VAR IF 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...
arr = [int(i) for i in filter(None, input().split(" "))] k = arr[0] sum = arr[1] num = "" if sum == 0 or sum > k * 9: if k == 1 and sum == 0: print(0, 0) else: print("-1 -1") else: while sum >= 9: num += "9" sum -= 9 k -= 1 if k >= 1: num += str(sum) ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NONE FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER 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...
import time I = lambda: list(map(int, input().split(" "))) N, s = I() mem = {} def maxDigits(n, s): if (n, s) in mem: return mem[n, s] elif n == 1 and s <= 9 and s > 0 or n == N == 1 and s <= 9: return str(s), True elif n < N and s == 0: return "0" * n, True elif n == 1 and s ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER RETURN BIN_OP STRING 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, s = input().split(" ", 1) m, s = int(m), int(s) def rev(a): return a[::-1] if 9 * m < s or s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: max1, min1 = "", "" i = 1 while i <= m: if s >= 9: s = s - 9 max1 = max1 + "9" ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR NUMBER 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 VAR STRING STRING ASSIGN VAR NUMBER WHILE VAR 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...
n, s = map(int, input().split()) s_save = s if s == 0 and n == 1: ansmax, ansmin = 0, 0 elif s == 0 and n > 1: ansmax, ansmin = -1, -1 elif s > n * 9: ansmax, ansmin = -1, -1 else: ansmax, ansmin = 0, 0 d, t = 0, 0 for i in range(n): if s > 0: d = min(9, s) else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR 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, s = map(int, input().split()) z = s maxn = "" minn = "" if s == 0: if m == 1: print(0, 0) else: print("-1 -1") elif s > 9 * m: print("-1 -1") else: for i in range(m): if s >= 9: maxn += str(9) s -= 9 elif s == 0: maxn += str(0) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL 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...
test = lambda m, s: s >= 0 and s <= 9 * m m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) else: m1, s1 = m, s mn, mx = "", "" fo = True while test(m1, s1) and m1 > 0: i = 1 if m1 == m else 0 f = True while i <= 9 and f: if test(m1 - 1, s1 - i): ...
ASSIGN VAR VAR NUMBER VAR BIN_OP NUMBER VAR 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 VAR VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER W...
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 det(m, s): return s < 0 or m * 9 < s m, s = map(int, input().split()) if det(m, s): print(-1, -1) elif s == 0 and m == 1: print(0, 0) elif s == 0: print(-1, -1) else: s2 = s m2 = m for i in range(m): if i == 0: for j in range(1, 10): if not det(m - 1...
FUNC_DEF RETURN VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR 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 VAR ASSIGN VAR VAR FOR VAR 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 solve_lrg(leng, num_l, req): if leng == 0 or req < 0: if req == 0: return "".join(list(map(str, num_l))) else: return [] if req < 10: num_l.append(req) req = 0 else: num_l.append(9) req -= 9 return solve_lrg(leng - 1, num_l, req...
FUNC_DEF IF VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN LIST IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER 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...
maxnum = [(0) for i in range(110)] minnum = [(0) for i in range(110)] m, s = list(map(int, input().split())) length = m sum_num = s if m * 9 < s: print("-1 -1") else: m = m - 1 while s > 9: minnum[m] = 9 m = m - 1 s = s - 9 if m == 0: minnum[m] = s else: minnu...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR 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...
length, n_sum = [int(x) for x in input().split()] if length > 1 and n_sum == 0: print("-1 -1") exit() if n_sum == 0: print("0 0") exit() maxes = [] zeros_count = 0 for i in range(0, length): max_value = min(n_sum, 9) n_sum -= max_value maxes.append(str(max_value)) if max_value == 0: ...
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 IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR 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...
m, s = map(int, input().split()) if s > m * 9: print(-1, -1) elif s == 0: if m == 1: print(0, 0) else: print(-1, -1) else: pos = 0 lost = s minAns = "" while (m - pos - 1) * 9 > lost: if pos == 0: minAns += "1" lost -= 1 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP 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 ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING WHILE BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER 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 = [int(i) for i in input().split()] output = [-1, -1] mini = [] maxi = [] if s == 0 and m == 1: output = [0, 0] if s >= 1 and s <= 9: mini.extend([(0) for i in range(m)]) maxi.extend([(0) for i in range(m)]) if m > 1: mini[0] = 1 mini[m - 1] = s - 1 maxi[0] = s elif m ==...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR IF 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...
I = lambda: list(map(int, input().split())) m, s = I() s1 = s if s == 0: if m == 1: print(0, 0) else: print(-1, -1) elif s > 9 * m: print(-1, -1) else: arr = [0] * m for i in range(0, m): if s > 9: arr[i] = 9 s = s - 9 else: arr[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR 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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL 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...
import sys m, s = map(int, sys.stdin.readline().strip().split(" ")) upp = 9 * m bot = 1 if m == 1 and s == 0: print(0, 0) elif s < bot or s > upp or m == 0: print(-1, -1) else: A = [0] * m A[0] = 1 for x in range(m): for y in range(10): if sum(A) == s: break ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR 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...
def genmn(): co9 = s // 9 prefix = s % 9 if prefix == 0: prefix = 9 co9 -= 1 if m == co9 + 1: return str(prefix) + "9" * co9 prefix -= 1 return "1" + "0" * (m - co9 - 2) + str(prefix) + "9" * co9 def genmx(): co9 = s // 9 appendix = s % 9 if m == co9: ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP STRING VAR FUNC_DEF 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...
def main(): m, n = [int(v) for v in input().split()] s = m digits1 = [] digits2 = [] total1 = n - 1 total2 = n if n == 0 and m == 1: print(0, 0) return if total1 < 0: print(-1, -1) return if m * 9 < n: print(-1, -1) return s1 = [(0)...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN IF BIN_OP VAR NUMBER VAR 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...
def main(): m, s = map(int, input().split()) if s == 0: if m == 1: print(0, 0) else: print(-1, -1) exit() for i in range(1, 10): if 0 <= s - i <= (m - 1) * 9: k = s - i a = [] for j in range(m - 1): a...
FUNC_DEF 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 FOR VAR FUNC_CALL VAR NUMBER NUMBER IF NUMBER BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR 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...
n = [int(j) for j in input().split()] if n[1] == 0 and n[0] == 1: print("0 0") elif n[1] == 0 or n[1] > 9 * n[0]: print("-1 -1") elif n[1] == 9 * n[0]: m = "" for k in range(n[0]): m = m + "9" print(m, m) else: x = n[1] % 9 y = int((n[1] - x) / 9) m = "" for k in range(y): ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER VAR NUMBER BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR 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...
m, s = input().split() m = int(m) s = int(s) if s / m == 0: if s + m == 1: a = b = 0 else: a = b = -1 elif 0 < s / m <= 1: sy = s - 1 n = sy // 9 if n != 0: sy = sy - n * 9 a = 10 ** (m - 1) + 10**n - 1 + sy * 10**n else: a = 10 ** (m - 1) + sy sy1 = s...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP 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 = 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: A = [0] * m a = [0] * m s1 = s for i in range(m): if s1 > 9: A[i] = 9 s1 -= 9 else: A[i] = s1 ...
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 NUMBER NUMBER IF 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 FOR VAR 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...
m, s = map(int, input().split()) def max_recur(m, s, a): if m == 0: return a if not a and s == 0: if m == 1: return 0 else: return -1 if 9 * m < s: return -1 digit = min(9, s) a += str(digit) return max_recur(m - 1, s - digit, a) def mi...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF BIN_OP NUMBER VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR FUNC_DEF 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...
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: x = (s - 1) // 9 y = (s - 1) % 9 if x + 1 == m: print("%s" % (y + 1) + "9" * x) else: num = [1] + [0] * (m - x - 2) + [y] + [9] * x print("".join(list(map(str, ...
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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL 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 can(spots, sum): return 9 * spots >= sum def biggest(m, s): if m == 1 and s <= 9: return str(s) if m == 1 and s >= 10: return "x" if m > 1: mx = min(9, s) return str(mx) + biggest(m - 1, s - mx) return "x" def smallest(m, s): res = "" for i in range(m)...
FUNC_DEF RETURN BIN_OP NUMBER VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR RETURN STRING FUNC_DEF ASSIGN VAR STRING FOR VAR 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...
l = input().split() d = int(l[0]) s = int(l[1]) if d == 1 and s == 0: print("0 0") elif s <= 0 or s > d * 9: print("-1 -1") else: b1 = (9 * d - s) // 9 b2 = (9 * d - s) % 9 s1 = (s - 1) // 9 s2 = (s - 1) % 9 big = 10**d - (1 + b2) * 10**b1 small = 10 ** (d - 1) + (1 + s2) * 10**s1 - 1 ...
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 STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER 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, n = (int(i) for i in input().split()) if n == 0 and m != 1 or m * 9 < n: print(-1, -1) elif n // 9 == m: print("9" * m, "9" * m) else: m1 = m m1 -= n // 9 m1 -= 1 maxim = "9" * (n // 9) + str(n % 9) + "0" * m1 if m1 == 0: minim = str(n % 9) + "9" * (n // 9) else: n -= ...
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 NUMBER NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP 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...
put = input().split() l = int(put[0]) s = int(put[1]) if s == 0 and l == 1: print(0, 0) exit() if s < 1 or s > 9 * l: print(-1, -1) exit() a = [0] * l b = [0] * l i = 0 k = -1 if l > 1: a[0] = 1 b[0] = 1 while True: if sum(a) == s: break if a[k] < 9: a[k] += 1 else: ...
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 EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR 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...
data = list(map(int, input().split())) ndigits = data[0] d_sum = data[1] if d_sum == 0: if ndigits > 1: print("-1 -1") else: print("0 0") elif 9 * ndigits < d_sum: print("-1 -1") else: to_minimal = d_sum minimal = "" for x in range(ndigits - 1): for number in range(9, -1,...
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 STRING EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR 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, k = map(int, input().split()) if k == 1: print("1" + "0" * (n - 1), "1" + "0" * (n - 1)) elif n == 1: if 0 <= k <= 9: print(k, k) else: print("-1 -1") else: ANS = ["1"] + ["0"] * (n - 2) + ["1"] k -= 2 if k < 0: print("-1 -1") else: ANS[0] = str(min(8, k) +...
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 IF VAR NUMBER IF NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP LIST S...
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, total = list(map(int, input().split())) adad_min = [] adad_max = [] nine_counter = 0 ans = [-1, -1] for i in range(length): adad_max.append(0) adad_min.append(0) temp = total while temp > 9: temp -= 9 nine_counter += 1 reminder = temp if nine_counter < length and total != 0: for i in range(n...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR 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 get_pairs(summ, m): def char(arr): return int("".join(map(str, arr))) if summ == 0 and m == 1: print(0, 0) return if summ > 9 * m or summ < 1: print(-1, -1) return min_array = [0] * m min_array[0] = 1 for i in range(m): diff = summ - sum(min_...
FUNC_DEF FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR 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...
def solve(m, s): if s == 0 and m > 1: print(*[-1, -1]) return 0 elif s == 0 and m == 1: print(*[0, 0]) return 0 elif 9 * m < s: print(*[-1, -1]) return 0 else: to = s max1 = [] while sum(max1) != s: if to >= 9: ...
FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER RETURN NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR 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...
import sys def main(): import sys a, b = map(int, sys.stdin.readline().split()) if not a: maxim = "-1" minim = "-1" elif not b: if a == 1: maxim = "0" minim = "0" else: maxim = "-1" minim = "-1" else: maxim = ...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR IF NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER 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...
n, sum = [int(i) for i in input().split()] q = sum % 9 w = sum // 9 if sum == 0: if n == 1: print("0 0") else: print("-1 -1") elif w < n - 1: if q != 0: print( "1", "0" * (n - w - 2), q - 1, "9" * w, " ", "9" * w...
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 IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER BIN_OP 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...
import sys m, s = [int(x) for x in input().split()] if m == 1 and s == 0: print("0 0") sys.exit() if s == 0: print("-1 -1") sys.exit() UPPER_BORDER = 10 LOWER_BORDER = -1 dp1 = [([UPPER_BORDER] * (s + 1)) for x in range(m + 1)] dp2 = [([LOWER_BORDER] * (s + 1)) for x in range(m + 1)] dp1[0][0] = 0 dp2[...
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 IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP 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...
n, m = map(int, input().split()) small = [9] * n big = [9] * n tmp = 9 * n i = 0 if m == 0 and n == 1: print("0 0") exit() canB = False while i < n: if tmp == m: canB = True break elif tmp > m: if tmp - m >= 9: big[i] -= 9 tmp -= 9 else: ...
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 NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR IF 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 = [int(x) for x in input().split()] if m > 1 and s < 1 or s > 9 * m: print(-1, -1) elif m == 1: print(s, s) elif s <= 9: min_num = [s, 10 + s - 1] max_num = [s, 10 * s] for i in range(2, m): min_num.append(min_num[i - 1] - 10 ** (i - 1) + 10**i) max_num.append(max_num[i - 1] * 1...
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 NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR LIST VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR LIST VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER 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 printListNum(arr): for i in arr: print(i, end="") print(" ", end="") def magic(): m, s = [int(x) for x in input().split()] if m > 1 and s == 0 or m * 9 < s: print("-1 -1") return lsMax = [0] * m for i in range(m): if s > 9: lsMax[i] = 9 ...
FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING FUNC_DEF 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 RETURN ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN 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...
m, s = map(int, input().split()) if s > m * 9 or s == 0 and m != 1: print(-1, -1, sep=" ") else: mx = [] m_ = m while m: temp = min(9, s) s -= temp m -= 1 mx.append(str(temp)) mn = list(reversed(mx)) if mn[0] == "0" and m_ != 1: i = 1 while i <= m_...
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 STRING ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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...
def p(a): if a <= 0: return 0 else: return a output = "" l, s = map(int, input().split(" ")) if s / l > 9 or s == 0 and l > 1: print("-1 -1") elif s == 0 and l == 1: print("0 0") else: n = str(s % 9) if s % 9 == 0: n = "" output = n + "9" * p(s // 9) if len(outp...
FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN VAR ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER 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...
import sys input = sys.stdin.readline def inp(): return int(input()) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) def can(m, s): return 0 <= s <= 9 * m m, s = invr() minn = "" sum = s for i in range(m): min_failed = True for d i...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN 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...
def sumDigits(S): return sum(int(ch) for ch in S) def soln(m, s): sOrig = s maxStr = [] for _ in range(m): curr = min(s, 9) s -= curr maxStr.append(str(curr)) maxVal = int("".join(maxStr)) if len(str(maxVal)) != m or s != 0: return "-1 -1" minStr = maxStr[::...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN STRING 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 = map(int, input().split()) if s == 0 and m > 1 or m * 9 < s: print(-1, -1) elif s == 0: print(s, s) else: mn = [0] * m mn[0] = 1 i = m - 1 sp = s - 1 while sp: if mn[i] == 9: i -= 1 else: sp -= 1 mn[i] += 1 mx = [0] * m i = 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR 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 IF VAR 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...
def findLargest(m, s): if s == 0: if m == 1: return 0 else: return -1 if s > 9 * m: return -1 res = [0] * m for i in range(0, m): if s >= 9: res[i] = 9 s = s - 9 else: res[i] = s s = 0 st ...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR BIN_OP NUMBER VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING 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 = [int(i) for i in input().split()] if s > 9 * m or s == 0 and m > 1: print(-1, -1) elif m == 1: print(s, s) else: m1 = "" m2 = "" bit = s // 9 m1 = "9" * bit if m != bit: m1 += str(s % 9) + (m - 1 - bit) * "0" if m == bit: m2 = m1 elif m - bit == 1: if m...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR IF VAR VAR VAR BIN_OP 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...
m, s = [int(a) for a in input().split()] maxx = "" minn = "" s1 = s s2 = s - 1 if s == 0 and m == 1: print(0, 0) elif s > 9 * m or s < 1: print(-1, -1) elif m == 1: print(s, s) else: for a in range(m): if s1 > 9: maxx += str(9) s1 -= 9 elif s1 == 0: ma...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR 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...
m, s = [int(i) for i in input().split()] if s > 9 * m: print("-1", "-1") elif s == 0 and m != 1: print("-1", "-1") else: M = [0] * m Mmax = [0] * m Mmin = [0] * m a9 = int(s / 9) for i in range(a9): M[i] = 9 b = s - 9 * a9 if b != 0: M[a9] = b for i in range(m): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL 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...
s = input().split(" ") m = int(s[0]) s = int(s[1]) s1 = s if s > m * 9 or m > 1 and s < 1: print("-1 -1") else: res = [(0) for i in range(m + 1)] s -= 1 for i in range(m - 1, 0, -1): if s > 9: res[i] = 9 s -= 9 else: res[i] = s s = 0 re...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER 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 = map(int, input().split()) a, b = 0, 0 if s > 9 * m or s < 1 != m: print(-1, -1) else: for i in range(m): if m > s // 9 + 1: c = 1 if (s - 1 - 9 * i) // 9 >= 1: b += 9 * 10**i elif s - 1 - 9 * i > 0: b += (s - 1 - 9 * i) * 10**i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER 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 m == 1 and s == 0: print("0 0") elif 9 * m < s or s == 0: print("-1 -1") else: k = (s - 1) // 9 r = s - k * 9 l = "9" * k z = m - len(l) a = ("1" if z > 1 else "") + "0" * (z - 2) + (str(r - 1) if z > 1 else str(r)) + l b = l + str(r) + "0" * (z - 1) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR FUNC_CALL 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...
def f(m, s): if m == 1 and s < 10: return str(s) if m == 1 and s > 9: return "F" if s > 9: return "9" + f(m - 1, s - 9) else: return str(s) + f(m - 1, 0) def g(m, s): s1 = s L = list() if m == 1 and s < 10: return s if m == 1 and s > 9: r...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER RETURN BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR 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...
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: mi = [0] * m mi[0] = 1 s -= 1 c = s // 9 c1 = s % 9 ma = [0] * m for i in range(c): mi[m - 1 - i] = 9 mi[m - 1 - c] += c1 s += 1 q = s // 9 q1 = 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 LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR 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...
def calcSum(nums): s = 0 for i in nums: s += i return s def findMin(nums, m, s): nums[0] = 1 for i in range(1, m): nums[i] = 0 sum = calcSum(nums) i = 0 diff = s - sum while True: if diff > 9: nums[-i - 1] = 9 i += 1 if i ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR 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 GivenLengthAndSumOfDigits(m, s): isPossible = NumberExists(m, s) if s == 0 and m == 1: return str(0), str(0) if isPossible: smallest = FindSmallestNumber(m, s) largest = FindLargestNumber(m, s) return smallest, largest else: return str(-1), str(-1) def Numbe...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR RETURN FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN 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, s = [int(v) for v in input().strip().split()] tempSum = s max_ = 0 if s == 0: if l == 1: print("0 0") else: print("-1 -1") else: for i in range(l): max_ *= 10 temp = min(tempSum, 9) tempSum -= temp max_ += temp if tempSum > 0: print("-1 -1") ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING 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 = [int(i) for i in input().split()] st = s if s <= 0 and m > 1 or s > m * 9: print("-1", "-1") exit() else: for i in range(m - 1, -1, -1): last = max(0, s - 9 * i) if last <= 0 and i == m - 1 and s != 0: last = 1 print(last, end="") s -= last print(" ", e...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL 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 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...
a, b = map(int, input().split()) if b > a * 9 or b == 0 and a > 1: print("-1 -1") else: max = "" while a > 0: x = 9 if b > 9 else b b -= x max += str(x) a -= 1 min = max[::-1] if min[0] == "0": for i in range(len(min)): if min[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 STRING ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING FOR VAR FUNC_CALL VAR FUNC_CALL 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 = map(int, input().split()) c = s // 9 * "9" if s % 9: c += str(s % 9) c += "0" * (m - len(c)) c2 = c[::-1] if c.count("0") and s != 0: c2 = list(c) i = c2.index("0") - 1 c2[i] = str(int(c2[i]) - 1) c2[-1] = "1" c2 = "".join(c2[::-1]) if int(m) * 9 < s or s == 0 and m > 1: print("-1", "...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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...
n, s = map(int, input().split(" ")) c = [] d = [] f = 0 t = s for i in range(n): if s > 9 * (n - i): f = 1 break b = max(0, s - 9 * (n - i - 1)) if i == 0 and i < n - 1: b = max(1, b) c.append(str(b)) s -= b if t > 9: d.append("9") t -= 9 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER 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 = input().split() m = int(m) s = int(s) if s > 9 * m: print("-1 -1") elif s < 1 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: a = s // 9 b = s % 9 max = "" max += a * "9" if a < m: max += str(b) while len(max) < m: max += "0" a = (s - 1...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR 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 S...
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] * m a[0] = 1 sum = 1 if s == 0 and m == 1: print(0, 0) elif s - sum < 0: print("-1 -1") elif s - sum == 0: for _ in range(len(a)): print(a[_], end="") print(" ", end="") for _ in range(len(a)): print(a[_], end="") else: k = (s - sum) // 9 ...
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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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...
m, s = map(int, input().split()) if s == 0 and m >= 2 or s > 9 * m: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: tmp1 = s tmp2 = s flag1 = 0 flag2 = 0 for i in range(m): if i == 0: if (m - i) * 9 >= tmp1: if (m - i - 1) * 9 < tmp1 - 1: ...
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 ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP BIN_OP 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...
import sys s = list(map(int, input().split())) n = s[0] m = s[1] if (n == 1) & (m == 0): print("0 0") sys.exit() if (m == 0) | (m > 9 * n): print("-1 -1") sys.exit() r = m - 1 d = 0 st1 = "" d0 = 0 while d < n: d = d + 1 d0 = min(r, 9) r = r - d0 if d < n: st1 = str(d0) + st1 ...
IMPORT 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 VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR 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...
m, s = map(int, input().split()) if s == 0 and m > 1 or m * 9 < s: print("-1 -1") exit() def find_max(m, s): ans = [0] * m i = 0 while s > 9: ans[i] = 9 s -= 9 i += 1 if i == m and s > 0: print("-1 -1") exit() ans[i] += s ans_1 = "".j...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING 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...
l, s = map(int, input().split()) ma = "" k = 0 for i in range(l): if k + 9 <= s: ma += "9" elif k < s: ma += str(s - k) else: ma += "0" k = sum([int(i) for i in ma]) mi = "" k = 0 for i in range(l): if k + 10 <= s: mi += "9" elif k + 1 < s: mi += str(s - k...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR STRING IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL 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...
a, b = map(int, input().split()) c = [0] * a n = [0] * a n[0] = 1 c[0] = 1 e = 0 f = a - 1 while 1: d = 0 for i in range(len(n)): d += n[i] if d == b: break n[f] += 1 if n[f] == 9: f -= 1 if f == -1: break while 1: d = 0 for i in range(len(c)): d +...
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 NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR 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 = map(int, input().split()) if m * 9 < s: print("-1 -1") exit() if s == 0 and m != 1: print("-1 -1") exit() k = s max = [] for i in range(m): if s < 10: max.append(s) s = 0 else: max.append(9) s -= 9 min = [] for i in range(m): if m == 1: min.appe...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR 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 VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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 min_and_max(m, s): if s == 0: if m == 1: return 0, 0 return -1, -1 max_num = 0 s_max = s for i in range(m): if s_max >= 9: max_num = max_num * 10 + 9 s_max -= 9 else: max_num = max_num * 10 + s_max s_max = 0 ...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER RETURN NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER FUNC_DEF 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 = [int(x) for x in input().split()] if s == 0 and m > 1 or s > 9 * m: print("-1 -1") exit(0) elif m == 1: mi = ma = s elif s % 9 == 0: if m == s // 9: mi = ma = "9" * m else: mi = "1" + "0" * max(0, m - s // 9 - 1) + "8" + "9" * (s // 9 - 1) ma = "9" * (s // 9) + "0" * m...
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 EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BI...
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()] m2 = m if n == 1 and m == 0: print(0, 0) elif m == 0 or n * 9 < m: print(-1, -1) else: max = 0 for i in range(n): if m >= 9: max = max * 10 + 9 m = m - 9 else: max = max * 10 + m m = 0 min = 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER 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...
import sys import time def read_line(cast=None): if cast is not None: return cast(input().strip()) else: return input().strip() def read_list(cast=int): return list(map(cast, read_line().split())) def solve(m, s): if s == 0 and m == 1: print("0 0") return if s =...
IMPORT IMPORT FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN 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...
b = list(map(int, input().split(" "))) le = b[0] su = b[1] sol = list() if le == 1 and su == 0: print("0 0") elif 9 * le >= su and su > 0: for a in range(le): if su - 9 > 0: sol.append("9") su -= 9 else: sol.append("{}".format(su)) su -= su su ...
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 IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING 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...
n = input().split() m, s = int(n[0]), int(n[1]) k = 0 o = 0 if s < 1 and m != 1 or s > 9 * m: print("-1 -1") else: for i in range(1, m + 1): if s >= 9: k += 9 * 10 ** (m - i) s -= 9 else: k += s * 10 ** (m - i) s = 0 s = int(n[1]) for i in ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR 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...
i = 0 m, s = map(int, input().split()) k = s if s == 0 and m == 1: print(0, 0) elif s == 0 or m * 9 < s: print(-1, -1) elif s == 1: x = "1" + (m - 1) * "0" print(x, x) else: s = k ans = 0 i = 0 while i < m: if s >= 9: ans += 9 ans *= 10 else: ...
ASSIGN VAR NUMBER 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 BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR ASSIG...