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...
a = input().split(" ", 2) length = int(a[0]) asum = int(a[1]) if length == 1 and asum == 0: print("0 0") elif asum == 0: print("-1 -1") elif asum > length * 9: print("-1 -1") else: ans1 = 0 ans2 = 0 str1 = "" str2 = "" if asum < 10: ans1 = 10 ** (length - 1) + asum - 1 an...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER 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 EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING 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 s == 0 and m > 1 or 9 * m < s: print(-1, -1) elif s == 0 and m == 1: print(0, 0) else: d = s // 9 r = s % 9 if r != 0: rez1 = "9" * d + str(r) else: rez1 = "9" * d rez2 = int(rez1[::-1]) rez2 = rez2 - 10 ** (len(str(rez2)) - 1) + 10 ** ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING 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()) if m * 9 < s or s == 0 and m != 1: print("-1 -1") else: minimum = [0] * m for i in range(1, s // 9 + 1): minimum[-i] = 9 if s % 9 != 0: minimum[-(s // 9) - 1] = s % 9 maximum = sorted(minimum, reverse=True) if minimum[0] == 0: for j in ran...
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 ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER 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...
dig, summ = map(int, input().split()) max_sum = dig * 9 def find_max(): quotient = summ / 9 remainder = summ % 9 nine = ["9"] * int(quotient) return remainder, nine if summ > max_sum: print("-1 -1") elif summ == 0 and dig == 1: print("0 0") elif dig == 1: print(str(summ) + " " + str(summ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR RETURN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EX...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) MIN = 10 ** (m - 1) MAX = 0 for i in range(s - 1): MIN = MIN + +(10 ** (i // 9)) for j in range(s): MAX = MAX + 10 ** (m - 1 - j // 9) if m == 1 and s == 0: print(0, 0) elif s > 9 * m or s == 0: print(-1, -1) else: print(MIN, MAX)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP 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...
import sys def sol(s): s1 = "1" t = True for i in range(1, len(s)): if s[i] != "0" and t: s1 += str(int(s[i]) - 1) t = False else: s1 += s[i] return s1 m, s = map(int, input().split()) n = s ans = "" for i in range(m): if s >= 9: ans +=...
IMPORT FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR 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...
def c489(x, y): if y == 0: if x == 1: return 0, 0 else: return -1, -1 if y > 9 * x: return -1, -1 m = y // 9 n = y - 9 * m if m == x: return int("9" * x), int("9" * x) s1 = "9" * m + str(n) + "0" * (x - m - 1) if n > 0: if x - m...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER RETURN NUMBER NUMBER IF VAR BIN_OP NUMBER VAR RETURN NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR RETURN FUNC_CALL VAR BIN_OP STRING VAR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR F...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def maximum(d, sum): if d > 1 and sum == 0: return -1 if sum > d * 9: return -1 i = 10 m = 0 while sum != 0: if sum >= 9: m = m * i + 9 sum = sum - 9 d = d - 1 else: m = m * i + sum sum = 0 d = d ...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR 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...
m, s = map(int, input().split()) def biggest_number(length, sum_digits): if length > 1 and sum_digits == 0 or length * 9 < sum_digits: return -1 number = "" curr_digit = 0 remaining_sum = sum_digits while remaining_sum > 0: number += str(min(remaining_sum, 9)) remaining_sum...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR RETURN NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR FUNC_CALL 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...
z = input().split() m = int(z[0]) n = int(z[1]) la = [] li = [] k = int(n / 9) if m > 1 and n == 0 or n > 9 * m: print("-1 -1") quit() else: for i in range(k): la.append("9") if k != m: s = n - 9 * k la.append(str(s)) t = m - k - 1 for i in range(t): la.append("0"...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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()) if s > m * 9 or s == 0 and m != 1: print("-1 -1") else: biggest = "9" * (s // 9) + (str(s % 9) if s % 9 != 0 else "") if len(biggest) < m: biggest += "0" * (m - len(biggest)) smallest = list(biggest[::-1]) if len(smallest) > 1: if smallest[0] == "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 BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR VAR VAR VAR BIN_OP STRING BIN_OP 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()) maxx = "9" * (s // 9) + (str(s % 9) if s % 9 != 0 else "") check = list({maxx}) if m == 1 and s == 0: print(0, 0) elif m < len(maxx) or (len(check) <= 1 and check[0] == "0" or check[0] == ""): print(-1, -1) else: k = m - len(maxx) maxx = maxx + "0" * k if "0" in maxx...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER 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...
ln, s = map(int, input().split()) if 9 * ln < s: print("-1 -1") elif s == 0 and ln == 1: print("0 0") elif s == 0 and ln != 1: print("-1 -1") else: n = (s + 8) // 9 x = (n - 1) * 9 if n > ln: print("-1 -1") elif n == ln: ans = str(s - x) + "9" * (n - 1) print(ans, ans...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR 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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR 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...
m, s = map(int, input(" ").split()) if s == 0 and m == 1: print(0, 0) elif s > m * 9 or s == 0: print(-1, -1) else: M = "9" * (s // 9) if s % 9 != 0: M += str(s % 9) M += "0" * (m - len(M)) m = sorted(M) if m[0] == "0": i = 0 while m[i] == "0": i += 1 ...
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 BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP STRING BIN_...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
ms = input().split() m, s = int(ms[0]), int(ms[1]) m1, s1 = m, s if s == 0 and m > 1 or s > 9 * m: print("-1 -1") else: mx = 0 mn = 10 ** (m - 1) while s1 >= 9: mx += 9 * 10 ** (m1 - 1) m1 -= 1 s1 -= 9 if s1 > 0: mx += s1 * 10 ** (m1 - 1) m2, s2 = 0, s - 1 whi...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER BIN_OP 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...
def findDigit(i, z): y = str(z) x = int(y[i]) return x a = input().split() b = [0] * int(a[0]) c = int(int(a[1]) / 9) d = int(a[1]) % 9 e = [] if (c < int(a[0]) or c == int(a[0]) and d == 0) and (int(a[1]) != 0 or int(a[0]) == 1): for i in range(c): b[i] = 9 if d != 0: b[c] = d els...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST IF VAR FUNC_CALL V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] minS = [(0) for i in range(m)] maxS = [(0) for i in range(m)] smin, smax = s, s if m == 1 and s < 10: print(s, s) elif s == 0 or s > 9 * m: print("-1 -1") elif s == 9 * m: print("9" * m + " " + "9" * m) else: minS[0] = 1 smin -= 1 maxS[: smax // 9] = [(9)...
ASSIGN VAR VAR FUNC_CALL VAR 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 VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR BIN_OP 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...
a, b = map(int, input().split()) yu = zheng = min_ = max_ = 0 if b > a * 9: print(-1, -1) elif b == a * 9: min_ = max_ = int(10**a - 1) print(min_, max_) elif a == 1 and b == 0: print(0, 0) elif b == 0: print(-1, -1) elif b >= 10: yu = int(b % 9) zheng = int(b / 9) max_ = int(10**a - 10 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR 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()) G = [(0) for _ in range(m)] S = [(0) for _ in range(m)] G[0] = min(s, 9) S[0] = max(1, s - 9 * (m - 1)) if S[0] > 9 or s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") else: for i in range(1, m): G[i] = G[i - 1] + min(9, max(0, s - G[i - 1])) ...
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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a = input() m, s = a.split() m = int(m) s = int(s) small = [0] * m big = [0] * m t = s // 9 if s % 9 == 0: t -= 1 if s > 9 * m or s == 0 and m > 1: print("-1 -1") elif m == 1 and s == 0: print("0 0") else: for i in range(t): big[i] = 9 big[t] = s - 9 * t if big[t] == 0: tt = t - ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR BIN_OP NUMBER 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...
def main(): m, s = map(int, input().split()) if s < 1 and m > 1 or s > 9 * m: print("-1 -1") return maxi = [] subs = s for i in range(m): if subs >= 9: maxi.append("9") subs -= 9 else: maxi.append(str(subs)) subs -= subs...
FUNC_DEF 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 RETURN ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) flag = 0 if s == 0: if m == 1: ma = 0 mi = 0 else: flag = 1 elif s % 9 != 0: ma = 10 ** (s // 9) - 1 if s % 9 != 0: ma = ma * 10 + s % 9 if len(str(ma)) < m: ma = ma * 10 ** (m - len(str(ma))) if len(str(ma)) != m: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP 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...
a, b = map(int, input().split()) if 9 * a < b: print(-1, -1) elif b == 0: if a != 1: print(-1, -1) else: print(0, 0) else: z = [0] * a z[-1] = 1 k = b - 1 a1 = k // 9 for n in range(a1): z[n] = 9 z[a1] += k % 9 s = z[::-1] z[a1] += 1 z[-1] -= 1 ...
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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN 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...
n = input() a = n.split() b = int(a[0]) i = b c = int(a[1]) l = 0 s = 0 if n == "1 0": print("0 0") elif c > 9 * b or c == 0: print("-1 -1") else: while i > 0: i -= 1 if c - 9 >= 0: c = c - 9 l = l + 9 * 10**i else: l = l + c * 10**i c ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR NUMBER IF 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...
import sys m, s = map(int, input().split()) if s == 0: if m == 1: print(0, 0) else: print(-1, -1) sys.exit(0) if m * 9 < s: print(-1, -1) sys.exit(0) if m == 1: print(s, s) sys.exit(0) l = int(s / 9) mx = "9" * l if l < m: mx += str(s % 9) if m - l - 1 > 0: mx += "0"...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR 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...
[m, s] = [int(x) for x in input().split()] if m == 1 and s == 0: print("0 0") elif s == 0 or m * 9 < s: print("-1 -1") else: mi = "" sm = 0 for i in range(0, m): b = 0 if i == 0: b = 1 for dig in range(b, 10): if sm + dig + 9 * (m - 1 - i) >= s: ...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER 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...
m, s = map(int, input().split()) a = [(0) for i in range(m)] b = [(0) for i in range(m)] s1 = s if m * 9 < s or m > 1 and s == 0: print("-1 -1") else: t = 0 while t < m and s > 0: if (m - t - 1) * 9 >= s: if t == 0: a[t] = 1 t += 1 s = s - ...
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 VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER 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 = [int(x) for x in input().split()] if m == 1 and s == 0: print("0 0") elif s <= m * 9 and s != 0: n = [0] * m n[0] = 1 p = -1 for i in range(1, s): n[p] += 1 if n[p] == 9: p -= 1 print(*n, sep="", end=" ") n = [0] * m n[0] = 1 p = 0 for i in rang...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s > 9 * m or s == 0 and m > 1: print("-1 -1") elif s == 0: print("0 0") else: mayor = [] menor = [] smenor = s for i in range(1, 10): if smenor - i <= (m - 1) * 9: smenor -= i menor.append(str(i)) break for j in ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) def ismax(m, s): op1 = str() if s == 0: return -1 elif s > m * 9: return -1 else: for i in range(m): if s > 9: op1 = op1 + "9" s -= 9 elif 0 < s <= 9: op1 = op1 + str(s) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING VAR NUMBER IF NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASS...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, s = map(int, input().split()) if s > 9 * n: print(-1, -1) elif s == 0 and n > 1: print(-1, -1) elif n == 1 and s == 0: print(0, 0) else: p = s // 9 q = s - 9 * p b = "" if q > 0: b = b + "9" * p + str(q) + "0" * (n - p - 1) else: b = b + "9" * p + "0" * (n - p) d =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR STRING 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, n = map(int, input().split()) min = [0] * m max = [0] * m sum, sum1 = n - 1, n min[0], max[0] = 1, 1 for i in range(m - 1, -1, -1): if sum + min[i] > 9: sum -= 9 - min[i] min[i] = 9 elif sum <= 0: break else: min[i] += sum sum = 0 break for i in range(m): ...
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 BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR ASSIGN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
data = [int(i) for i in input().split()] n, s = data if 0 < s < n * 9: a = s // 9 b = s % 9 if a == 0: s1 = 10 ** (n - 1) + b - 1 s2 = b * 10 ** (n - 1) elif a < n - 1: if b == 0: s1 = ["1", "0" * (n - a - 1), "8", "9" * (a - 1)] s2 = ["9" * a, "0" * (n - ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR IF NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF 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...
__author__ = "Rakshak.R.Hegde" m, s = map(int, input().split()) if m == 1 and s == 0: print("0 0") elif s / m > 9 or s == 0: print("-1 -1") else: num = [9] * m psum = 9 * m minDiff = min(8, psum - s) num[0] -= minDiff psum -= minDiff for i in range(1, m): minDiff = min(9, psum - ...
ASSIGN VAR STRING 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 VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER 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()) max_result, min_result = -1, -1 data = [(9) for i in range(m)] if m == 1 and s <= 9: print(s, s) exit() def get_max_result(): global max_result _data = data[:] for i in range(m): for j in range(8, -1, -1): _data[-i - 1] = j sum_data ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
params = input().split(" ") dig, theSum = [int(i) for i in params] def findNonZero(s): for idx, c in enumerate(s): if c != "0": return idx else: return -1 if theSum > dig * 9: print("-1 -1") elif dig == 1: print(str(theSum) + " " + str(theSum)) elif theSum == 0: print...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING RETURN VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER 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 IF VAR NUMBER EXPR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
length, total = [int(x) for x in input().split()] min_num = -1 max_num = -1 if total <= 9 and length == 1: min_num = total max_num = total elif total <= 9 * length and total != 0: q = total // 9 rem = total % 9 num = ["0"] * length if q == length: num = ["9"] * length else: n...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR IF VAR VAR ASSIGN VAR BIN_OP LIST 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 = [int(__) for __ in input().strip().split()] big, small = "", "" if s == 0: if m > 1: big = "-1" else: big = "0" else: sc = s * 1 if s > 9 * m: big = "-1" else: while sc > 0: if sc >= 9: big += "9" sc -= 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING STRING IF VAR NUMBER IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER 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...
n, s = map(int, input().split()) l = [0] * n h = [0] * n p = s % n if s > 9 * n: print("-1 -1") elif s == 0 and n != 1: print("-1 -1") else: nines = s // 9 k = nines remainder = s % 9 i = -1 while nines: l[i] = 9 i -= 1 nines -= 1 index = n + i if index == 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF 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 VAR ASSIGN 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...
from sys import stdin, stdout input = lambda: stdin.readline().strip() a, b = [int(i) for i in input().split()] if a == 1 and b == 0: print(0, 0) elif b == 0: print(-1, -1) else: s = "" pf = -1 sum1 = b for i in range(0, a): if sum1 > 9: s = s + str(9) sum1 = sum...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = list(map(int, input().split())) if m * 9 < s or m == 0 or s == 0 and m > 1: print("-1 -1") elif s == 0: print("0 0") else: _min = 10 ** (m - 1) _max = min(s, 9) * 10 ** (m - 1) _min = [int(x) for x in str(_min)] _max = [int(x) for x in str(_max)] _s = s - 1 for i in range(m - 1, -...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER 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...
m, s = map(int, input().split()) intermediate, ans, s1 = "", 0, s if m == 1 and s == 0: print("0 0") else: for i in range(m): for j in range(10): if not (i == 0 and j == 0) and (s - j >= 0 and s - j <= 9 * (m - i - 1)): intermediate += str(j) s -= j ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR STRING NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
__author__ = "Bian" m, s = [int(x) for x in input().split()] if s > m * 9 or s < 0 or s == 0 and m != 1: print("-1 -1") exit() s_bucket = s if m == 1 and s == 0: print("0", end="") else: pr = max(1, s_bucket - 9 * (m - 1)) print(pr, end="") s_bucket -= pr for i in range(m - 2, -1, -1): pr = ...
ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP V...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
l, s = map(int, input().split()) if l == 1 and s == 0: print(0, 0) elif s == 0 or s > 9 * l: print(-1, -1) else: mystr = "" for x in range(l): if s >= 9 and s != 0: mystr = mystr + "9" s -= 9 elif s < 9 and s != 0: mystr = mystr + str(s) 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 STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR STRING VAR NUMBER IF VAR NUMBER 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...
def can(m, s): return s <= 9 * m and s >= 0 mn = "" ss = 0 m, s = map(int, input().split()) for i in range(m): for d in range(10): if can(m - i - 1, s - ss - d) and (d != 0 or i != 0 or m == 1): ss += d mn += str(d) break else: print(-1, -1) brea...
FUNC_DEF RETURN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR 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, s = [int(i) for i in input().split()] if s == 0 and l > 1 or s > 9 * l: print("-1 -1") else: ma = "" for j in range(0, l): if s - 9 * j >= 0: ma += str(min(9, s - 9 * j)) else: ma += "0" e = list(ma) e.sort() mi = "" num = 0 if e[0] != "0" or l ...
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 ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR VAR STRING ASSIGN 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 = [int(x) for x in input().split()] n = [0, 0] l = [] if s > 9 * m or s < 0 or s == 0 and m > 1: n = [-1, -1] elif s == 0 and m == 1: n = [0, 0] else: for i in range(0, m): a = int(min(s, 9)) l.append(a) s = s - a n[0] = n[0] * 10 + a d = 0 e = 0 for i in ran...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 0 and m == 1: print(0, 0) elif s > 9 * m or s == 0: print(-1, -1) else: k = s a, b = [], [] for i in range(m): if s >= 10: a.append("9") b.append("9") s -= 9 k -= 9 else: a.append(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 BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
def logic(l, s): if s > 0 and s <= l * 9: l1 = [(0) for i in range(l)] l1[0] = 1 s1 = s s -= 1 i = l - 1 while s: while s and l1[i] < 9: l1[i] += 1 s -= 1 i -= 1 ans = "" for i in l1: ...
FUNC_DEF IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR WHILE VAR VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a = [int(i) for i in input().split()] m = a[0] s = a[1] if s == 0 and m == 1: print(s, s) elif s == 0: print(-1, -1) else: arr = [(0) for i in range(m)] arr1 = [(0) for i in range(m)] s1 = s for i in range(m): if s >= 9: arr[i] = 9 arr1[m - i - 1] = 9 ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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 = list(map(int, input().split())) if 9 * m < s or s == 0 and m > 1: print(-1, -1) elif s == 0 and m == 1: print(0, 0) else: x, y = divmod(s, 9) postfix = "" if y != 0: postfix = str(y) biggest = "9" * x + postfix + (m - x - len(postfix)) * "0" smallest = biggest[::-1] if m -...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR 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...
m, s = map(int, input().split()) s1 = s if m == 1 and s == 0: print(0, 0) exit() if s == 0 or s > 9 * m: print(-1, -1) exit() if s == 1: print(1 * 10 ** (m - 1), 1 * 10 ** (m - 1)) exit() ans = 1 * 10 ** (m - 1) s -= 1 i = 0 while s: if s <= 9: ans += s * 10**i s -= s els...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR 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...
class Solution: def __init__(self): self.m, self.s = map(int, input().split()) def solution(self): if self.m == 1 and self.s == 0: print(0, 0) elif self.m * 9 < self.s or self.s == 0: print(-1, -1) else: print( 10 ** (self.m -...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. 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 g(x, y): if y >= 9: return 9 else: return y m, s = map(int, input().split()) s1, s2 = m, s q = m a = [] h = "" t = "" if m == 0 or s > 9 * m: print("-1", "-1") elif s == 0: if m == 1: print(0, 0) else: print(-1, -1) else: if s > 9 * m - 8: ozo = s - ...
FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL 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...
m, s = [int(i) for i in input().split()] b = s if m == 1: if 0 <= s <= 9: print(s, s) else: print("-1 -1") if m > 1: if s > 9 * m or s == 0: print("-1 -1") else: n = [] for i in range(m): if s >= 9: n.append(9) s -= 9 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER IF NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
import sys input = sys.stdin.readline read_tuple = lambda _type: map(_type, input().split(" ")) def _min(m, s): if m == 1 and s == 0: return 0 if s == 0: return -1 curr_sum = 1 idx = m - 1 res = [1] + [(0) for _ in range(m - 1)] while idx > 0 and curr_sum != s: if s - ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR IF BIN_OP VAR VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if s == 0 and m != 1 or 9 * m < s: print(-1, -1) elif m == 1: print(s, s) else: x = "" t = s while t > 0: a = min(9, t) t -= a x += str(a) while len(x) < m: x += "0" t = s t -= 1 y = "" while t > 0: a = min(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VA...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
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: maximo = [] while sum(maximo) + 9 < s: maximo += [9] maximo += [s - sum(maximo)] for _ in range(l - len(maximo)): maximo += [0] minimo = maximo[::-1] ...
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 LIST WHILE BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR LIST NUMBER VAR LIST BIN_OP VAR FUNC_CALL VAR VAR 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 inp(): return map(int, input().split()) m, s = inp() ma, mi, smax, smin = list(str(10 ** (m - 1))), list(str(10 ** (m - 1))), s, s - 1 for i in range(len(ma)): if smax >= 9: ma[i] = str(int(ma[i]) + (9 - int(ma[i]))) else: ma[i] = str(int(ma[i]) + (smax - int(ma[i]))) smax -= int(m...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) if m == 1 and s == 0: print(0, 0) exit() t = s r = [(0) for i in range(m)] i = 0 r[i] = min(s, 9) s = s - r[i] i = 1 while s > 0 and i < len(r): r[i] = min(s, 9) s = s - r[i] i = i + 1 if s == t or s > 0: ans = -1 else: for i in range(len(r)): r[i] = ...
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 ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER 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 maximize(m, s): ans = [9] * m val = 9 * m for i in range(m - 1, -1, -1): if val - 9 > s: ans[i] = 0 val -= 9 else: ans[i] = s - (val - 9) break return "".join([str(d) for d in ans]) def minimize(m, s): ans = [1] + [0] * (m - 1) ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST 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 = [int(x) for x in input().split()] a = int(s / 9) b = s % 9 if m == 1: if s <= 9: min_ = s max_ = s else: min_ = -1 max_ = -1 elif s < 1 or s > 9 * m: min_ = -1 max_ = -1 elif s <= 9: min_ = "1" + "0" * (m - 2) + str(s - 1) max_ = str(s) + "0" * (m - 1) elif...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN 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...
a, b = map(int, input().split()) if a == 1 and b == 0: print(0, 0) elif b == 0: print(-1, -1) elif b > a * 9: print(-1, -1) else: largest = "" c = b for i in range(a): if b >= 9: largest = largest + "9" b -= 9 else: largest = largest + str(b) ...
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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRIN...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
pieces = [int(i) for i in input().split()] m = pieces[0] s = pieces[1] if s == 0 and m == 1: print(0, 0) elif s == 0: print(-1, -1) elif 9 * m < s: print(-1, -1) elif s // 9 == m: da = [str(9)] * m xiao = [str(9)] * m print("".join(xiao), "".join(da)) elif m == 1: print(s, s) elif s // 9 == ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST 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...
[m, S] = input().split() MAX = [] MIN = [] s = int(S) if int(s) <= 0 and int(m) != 1 or int(s) > 9 * int(m): print("-1 -1") elif int(s) == 0 and int(m) == 1: print("0 0") else: for i in range(0, int(m)): s -= 9 if s <= 0: MAX.append(int(s) + 9) s = 0 else: ...
ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR 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 == 0 and m == 1: print(0, 0) elif s == 0 and m > 1: print(-1, -1) elif m * 9 < s: print(-1, -1) else: temp = s big = [] while s != 0: if s - 9 < 0: big.append(str(s)) rem = s break else: big.app...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR NUMBER 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...
n, s = [int(x) for x in input().split()] if s / 9 > n and s != 0 or s == 0: if n == 1 and s == 0: print(0, 0) else: print(-1, -1) else: c = s // 9 max = "".join(["9" for i in range(c)]) if c != n: max += str(s % 9) max += "".join(["0" for i in range(n - c - 1)]) min =...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING STRING VAR FUNC_CALL VAR VAR IF VAR VAR VAR 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...
n, s = map(int, input().split()) S1, S2 = "", "" s1 = s2 = s if 9 * n < s or s == 0 and n != 1: print("-1 -1") elif n == 1 and s == 0: print("0 0") else: for i in range(n): if 9 * (n - i) == s1: S1 += "9" s1 -= 9 elif s1 + 9 >= 9 * (n - i) > s1: X = s1 // ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR VAR VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER BIN_OP VAR VAR VAR VAR STRING VAR NUMBER 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 = map(int, input().split()) stmax = "" stmin = "" lst = [] stmin1 = "" if s == 0: if m == 1: print("0 0") else: print("-1 -1") if s <= 9 * m: for i in range(0, m): x = min(9, s) stmax = stmax + str(x) s = s - x if s > 0: print("-1 -1") for i in ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN 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...
n = input() m = [] for i in n.split(): m.append(int(i)) a = m[0] b = m[1] c = m[1] q = "" p = "" if b > a * 9: print(-1, -1) elif b == 0 and a != 1: print(-1, -1) elif b == 0 and m == 1: print(0, 0) elif b <= a * 9: for k in range(a): if b >= 10: q = "9" + q b = b - 9...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER 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...
A = input() num = A.split(" ") numreal = [int(i) for i in num] resultmax = "" resultmin = "" if numreal[1] > numreal[0] * 9 or numreal[1] < 0 or numreal[1] == 0 and numreal[0] != 1: print("-1 -1") else: digi9 = numreal[1] // 9 digix = numreal[1] % 9 for i in range(0, digi9): resultmax += "9" ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = map(int, input().split()) res1 = "" res2 = "" space = s - 1 space2 = s flag = False if s > m * 9: flag = True for i in range(m): if space >= 9: res1 += "9" space -= 9 elif 9 > space > 0: res1 += str(space) space = 0 if space2 >= 9: res2 += "9" space...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER IF NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR 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...
mn = input().split() m = int(mn[0]) n = int(mn[1]) temp = n A = [(0) for i in range(0, m)] B = [(0) for i in range(0, m)] if m == 1 and n == 0: print("0 0") elif n < 1 or n > 9 * m: print("-1 -1") else: A[0] = 1 n -= 1 for i in range(m - 1, -1, -1): if n > 9: A[i] += 9 el...
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 NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP 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...
m, s1 = map(int, input().split()) ans1, ans2 = [], [] s2 = s1 for i in range(m): valid = range(s1 - 9 * (m - i - 1), s1 + 1) if i == 0 and m != 1: for x in range(1, 10): if x in valid: ans1.append(x) s1 -= x break else: for x in ran...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR EXPR 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...
m, s = map(int, input().strip().split()) if m == 1 and s == 0: print(0, 0) exit() elif s < 1 or s > 9 * m: print(-1, -1) exit() def sum_digits(n): return sum([int(x) for x in str(n)]) def increment_digits(number, how_many): number = sorted([int(x) for x in str(number)]) for i in range(le...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR 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 FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF 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 m > 1 and s == 0 or s > 9 * m: print("-1 -1") elif m == 1 and s == 0: print("0 0") else: s -= 1 nines = s // 9 remain = s % 9 if m > nines + 1: ans1 = "1" + (m - nines - 2) * "0" + str(remain) + nines * "9" else: ans1 = str(remain + 1) + ni...
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 VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = input().split() m = int(m) s = int(s) mi = 0 ma = 0 if s > 0 and s <= m * 9: if s > 9 * m - 8: for i in range(m): mi += 9 * 10**i mi -= (9 * m - s) * 10 ** (m - 1) mi = str(mi) mini = list(mi) mini.reverse() ma = "".join(mini) else: a = ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP 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()) mini = 0 maxi = 0 ost = s % 9 divi = s // 9 if divi == m - 1: mini = str(ost) + "9" * divi maxi = "9" * divi + str(ost) print(mini, maxi, end=" ") elif m > 1 and s == 9: mini = "1" + "0" * (m - 2) + str(int(s) - 1) maxi = str(s) + "0" * (m - 1) print(mini, maxi, ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING 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...
def make_small(m, s): if s == 0: return -1 if m > 1 else 0 s -= 1 result = "" for i in range(m): digit_to_append = min(9, s) result += str(digit_to_append) s -= digit_to_append result = result[::-1] result = list(result) result[0] = str(int(result[0]) + 1) ...
FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL 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...
inputs = input().split() num_length = int(inputs[0]) digits_sum = int(inputs[1]) if digits_sum > 9 * num_length or digits_sum == 0 and num_length > 1: print("-1 -1") elif digits_sum == 0 and num_length == 1: print("0 0") else: min_array = [1] + [(0) for x in range(num_length - 1)] max_array = [1] + [(0)...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_O...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
from sys import stdin m, s = map(int, stdin.readline().rstrip().split()) if m * 9 < s: print(-1, -1) elif m == 1: print(s, s) elif s == 0: print(-1, -1) else: large = s largest = "" for x in range(m): step = min(9, large) large -= step largest += str(step) small = s ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR 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 == 1 and s == 0: print("0 0") else: ms = "" sm = s for i in range(m): a = 9 while a >= 0: if a <= sm: ms = ms + str(a) sm = sm - a break else: a = a - 1 if sm...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBE...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a = input().split(" ") m = int(a[0]) s = int(a[1]) if m == 1 and s < 10: print(str(s) + " " + str(s)) elif s < 1 or s > m * 9: print("-1 -1") else: n1 = [0] * m n1[0] = 1 e = s - 1 pos = m - 1 while e > 9: n1[pos] += 9 e -= 9 pos -= 1 n1[pos] += e ans = "" ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER 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 findmax(n, s): a = [] for i in range(n): if s >= 9: a.append(9) s -= 9 else: a.append(s) break for i in range(len(a), n): a.append(0) s1 = "" for i in a: s1 += str(i) return s1 def findmin(n, s): s = s - 1 ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST 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...
n, k = map(int, input().split()) a = [] b = [] if k == 0: if n == 1: print("0 0") else: print("-1 -1") a.append(-1) if k > n * 9 and len(a) == 0: a.append(-1) print("-1 -1") if len(a) == 0: a.append(1) for i in range(n - 1): a.append(0) p = k k -= 1 for i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL 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()) mx, mi, a, b = [], [], 0, 0 if s == 0 and m > 1: print("-1 -1") quit() if s == 0 and m == 0: print("0 0") quit() while s > 0: if s > 9: mx.append(9) s -= 9 a += 1 elif s > 0: mx.append(s) a += 1 s = 0 if s == 0:...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR LIST LIST NUMBER NUMBER 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER 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 input_split(f): return map(f, input().split()) def main(): m, s = input_split(int) sma = [0] * m lar = [9] * m if m > 1: sma[0] = 1 i, c = -1, 1 while sum(sma) != s and i >= -m: sma[i] = c c += 1 if c == 10: i, c = i - 1, 1 sma.sort() ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF 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...
line = input().split() m = int(line[0]) s = int(line[1]) minans = "" maxans = "" x = 0 y = 0 if m == 1 and s == 0: print("0 0") elif s > 9 * m or s == 0: print("-1 -1") else: a1 = max([s - 9 * (m - 1), 1]) minans = minans + str(a1) x = x + a1 for i in range(m - 1): a = max([s - x - 9 * (...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR LIS...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
a = input() m = int(a.split()[0]) s = int(a.split()[1]) k = 0 if 9 * m < s: print("-1 -1") elif s == 0 and m > 1: print("-1 -1") elif s == 0 and m == 1: print("0 0") elif s <= 9 and s > 0: print(10 ** (m - 1) + s - 1, 10 ** (m - 1) * s) else: if (s - 1) % 9 == 0 and s != 10: for i in range(m...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP NUMBER VAR 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 IF VAR NUMBER 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...
Length, Sum = [int(a) for a in input().split()] if Sum == 0: if Length == 1: print(0, 0) else: print(-1, -1) elif Sum > Length * 9: print(-1, -1) else: MaxList = [0] * Length MinList = [0] * Length Max = "" Min = "" SumMin = Sum - 1 SumMax = Sum for digit in range...
ASSIGN VAR 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 VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING ASSIGN VAR STRING 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...
import sys m, s = [int(i) for i in input().split(" ")] son1 = [] son2 = [] s1 = s s2 = s for i in range(m): son1.append(0) son2.append(0) if s1 > 0: son1[0] = 1 s1 -= 1 for i in range(m): if s1 > 9: if son1[m - i - 1] + 9 < 10: son1[m - i - 1] += 9 s1 -= 9 elif s...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR B...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. 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 = map(int, input().strip().split()) if n > 9 * m: print("-1 -1") elif m == 1: print(n, n) elif n == 0: print(-1, -1) elif n == 9 * m: print("9" * m, "9" * m) elif n > (m - 1) * 9: print(str(n % 9) + "9" * (m - 1), "9" * (m - 1) + str(n % 9)) else: print( "1" + "0" * (m - (n - 1) // ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR IF VAR BIN_OP 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...
MOD = 10**9 + 7 I = lambda: list(map(int, input().split())) n, s = I() copys = s if s == 0 and n != 1 or 9 * n < s: print(-1, -1) elif n == 1: print(s, s) else: ss = "" for i in range(9, 0, -1): k = s // i ss += str(i) * k s -= i * k if len(ss) < n: ss = ss + "0" * (n...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER 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 VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR 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()) mn = "" mx = "" s1 = s2 = s if s > 0 and s <= 9 * m: while m > 0: if s1 >= 9: mx += "9" s1 -= 9 else: mx += str(s1) s1 = 0 if (m - 1) * 9 >= s2 - 1 and mn == "": mn += "1" s2 -= 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR WHILE VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR STRING VAR STRING VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n = input().split() m = int(n[0]) s = int(n[1]) if s == 0 and m == 1: print("0 0") if s == 0 and m >= 2 or s > 9 * m: print("-1 -1") if s <= 9 and s > 0: a = 10 ** (m - 1) + s - 1 b = s * 10 ** (m - 1) print("%d %d" % (a, b)) if s > 9 and s < 9 * m: c = s // 9 e = (s - 1) // 9 b = 0 ...
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 NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUM...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
n, s = map(int, input().split()) sma = [0] * n lar = [0] * n sma[0] = 1 if n == 1 and s == 0: print(0, 0) exit() elif n > 1 and s == 0: print(-1, -1) exit() elif s > 9 * n: print(-1, -1) exit() else: ds = s - 1 for i in range(n - 1, -1, -1): mm = min(9, ds) sma[i] += mm ...
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 IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR BIN_OP 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...
def abc(): m, s = input().split() m, s = int(m), int(s) if s == 0: if m == 1: print(0, 0) return else: print(-1, -1) return maxi = [] mini = [] for i in range(m): t = min(9, s) maxi.append(t) s -= t if s ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN EXPR FUNC_CALL VAR NUMBER NUMBER RETURN ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER 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()) s1 = s m1 = m mini = 0 max1 = 0 while m > 0: num1 = -1 num2 = -1 for i in range(9, -1, -1): if s - i >= 0 and i != 0: num1 = i break elif s - i >= 0 and max1 > 0: num1 = i break elif s - i >= 0 and m1 ==...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER 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...
str1 = input() a = int(str1.split()[0]) b = int(str1.split()[1]) if 9 * a < b: print("-1 -1") elif 1 > b: if a == 1: print(0, 0) if a != 1: print("-1 -1") else: c = b // 9 d = b % 9 n = 0 p1 = 0 p2 = 0 while n < c: p1 = p1 + 9 * 10 ** (a - n - 1) n = n...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR ...
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes. -----Input----- The single line of the input co...
m, s = [int(i) for i in input().split()] if s == 0 and m == 1: print("0 0") exit() if s == 0 or s > 9 * m: print("-1 -1") exit() max_ = "" min_ = "" a = s for i in range(m): if a >= 9: max_ += str(9) elif a < 0: max_ += str(0) else: max_ += str(a) if a > 9: ...
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 VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR...