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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n = input().split()
n[0] = int(n[0])
n[1] = int(n[1])
if n[1] == 0:
if n[0] == 1:
print("0 0")
if n[0] != 1:
print("-1 -1")
elif n[0] * 9 < n[1]:
print("-1 -1")
else:
i = (n[1] - 1) // 9
q = (n[1] - 1) % 9
mi = 10 ** (n[0] - 1) + q * 10**i
while i > 0:
mi += 9 * 10 ** (i - 1)
i = i - 1
ii = n[1] // 9
qq = n[1] % 9
if qq == 0:
ma = ii * "9" + (n[0] - ii) * "0"
else:
ma = ii * "9" + str(qq) + "0" * (n[0] - ii - 1)
print(mi, ma) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP NUMBER VAR WHILE VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | l, d = input().split()
d = int(d)
l = int(l)
total = 0
mini = 0
f = int(d)
if d > 0 and d <= l * 9:
for i in range(l, 0, -1):
if f - 9 > 0 and f - 9 <= l * 9:
f = f - 9
total += 9 * 10 ** (i - 1)
else:
total += f * 10 ** (i - 1)
break
if d >= (l - 1) * 9 + 1:
mini = (d - (l - 1) * 9 + 1) * 10 ** (l - 1) - 1
else:
k = d - 1
for i in range(l):
if k - 9 > 0 and k - 9 <= l * 9:
k = k - 9
mini += 9 * 10**i
else:
mini += k * 10**i
mini += 10 ** (l - 1)
break
print(mini, total)
elif l == 1 and d == 0:
print("0 0")
else:
print("-1 -1") | 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 ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
s_tp = [s, s]
m_tp = [m, m]
sm_num = ""
lr_num = ""
for i in range(m):
for j in range(int(not i), 10):
if m_tp[0] == 1:
sm_num += str(s_tp[0])
break
if (s_tp[0] - j) / (m_tp[0] - 1) <= 9 and s_tp[0] - j >= 0:
s_tp[0] -= j
m_tp[0] -= 1
sm_num += str(j)
break
for j in range(9, -1, -1):
if m_tp[1] == 1:
lr_num += str(s_tp[1])
break
if (s_tp[1] - j) / (m_tp[1] - 1) <= 9 and s_tp[1] - j >= 0:
s_tp[1] -= j
m_tp[1] -= 1
lr_num += str(j)
break
if m_tp[0] == 1 and m_tp[1] == 1 and (m > 1 and s != 0):
print(sm_num, lr_num)
elif m == 1 and s <= 9:
print(s, s)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
su = s
m2 = m
if m > 1 and s == 0:
print("-1 -1")
exit()
elif s / m > 9:
print("-1 -1")
exit()
elif m == 1 and s == 0:
print("0 0")
exit()
else:
d = 0
while m != 0:
if s > 9:
e = 9
else:
e = s
d += e * 10 ** (m - 1)
s -= e
m -= 1
k = su
c = ""
for i in range(m2 - 1, -1, -1):
j = max(0, k - 9 * i)
if j == 0 and i == m2 - 1:
j = 1
c += str(j)
k = k - int(j)
print(c, d) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING 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 NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, m = map(int, input().split())
if n * 9 < m or m == 0 and n > 1:
print(-1, -1)
else:
k = (m - 1) // 9
if m > 0:
l = (m - 1) % 9 + 1
else:
l = 0
x = 0
y = 0
for i in range(k):
x = x * 10 + 9
if n - k == 1:
x += l * 10**k
elif n - k > 1:
if l > 1:
x += (l - 1) * 10**k + 10 ** (n - 1)
else:
x += 10 ** (n - 1) * l
k = m // 9
l = m % 9
for i in range(k):
y = y * 10 + 9
if n > k:
y = y * 10 + l
y = y * 10 ** (n - k - 1)
print(x, y) | 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 NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | j = [int(i) for i in input().split(" ")]
leng = j[0]
summ = j[1]
if leng == 1 and summ == 0:
print("0 0")
elif leng * 9 < summ or summ <= 0:
print("-1 -1")
else:
mi = []
ma = []
for i in range(leng):
mi.append(0)
ma.append(0)
i = 0
while summ > 9:
mi[leng - 1 - i] = 9
ma[i] = 9
summ = summ - 9
i += 1
if summ <= 9:
ma[i] = summ
if ma.count(0) > 0:
mi[leng - 1 - i] = summ - 1
mi[0] = 1
else:
mi[leng - 1 - i] = summ
mi = "".join(str(x) for x in mi)
ma = "".join(str(x) for x in ma)
print(mi, ma) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | N, s = [int(i) for i in input().split()]
if s > 9 * N or s < 1 and N > 1:
print("-1 -1")
elif s == 9 * N:
print("9" * N + " " + "9" * N)
else:
print()
a = s // 9
b = s % 9
max = "9" * a + str(b) + "0" * (N - 1 - a)
if N == a + 1:
min = str(b) + "9" * a
elif b != 0:
min = "1" + "0" * (N - 2 - a) + str(b - 1) + "9" * a
else:
min = "1" + "0" * (N - a - 1) + "8" + "9" * (a - 1)
print(min + " " + max) | 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 STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER STRING BIN_OP STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | s = input().split()
a = int(s[0])
b = int(s[1])
if b / a > 9 or b / a <= 0:
if a == 1 and b == 0:
print("0", "0")
else:
print("-1", "-1")
else:
k = int((b - 1) / 9)
j = b - 1 - k * 9
n = ""
if a == k + 1:
l = [str(j + 1)] + ["9"] * k
t = l[:]
t.reverse()
else:
l = ["1"] + ["0"] * (a - k - 2) + [str(j)] + ["9"] * k
t = ["9"] * k + [str(j + 1)] + ["0"] * (a - k - 1)
if l[len(l) - 1] == 0:
print(n.join(l), n.join(l))
else:
print(n.join(l), n.join(t)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP LIST STRING VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP BIN_OP VAR VAR NUMBER LIST FUNC_CALL VAR VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST STRING VAR LIST FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP LIST STRING BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | X = input().split(" ")
a = int(X[0])
b = int(X[1])
Y = []
Z = []
if b == 0:
if a == 1:
print("0 0")
else:
print("-1 -1")
if b > 9 * a or b < 0:
print("-1 -1")
elif b != 0:
if b < 9 * (a - 1) and b != 0:
b = b - 1
counter = 1
while counter * 9 <= b:
Y.append(9)
counter = counter + 1
Y.append(b - (counter - 1) * 9)
while len(Y) < a - 1:
Y.append(0)
Y.reverse()
Y = [1] + Y
for i in range(len(Y)):
print(Y[i], end="")
b = b + 1
elif b >= 9 * (a - 1) and b != 0:
counter = 1
while counter * 9 <= b:
Y.append(9)
counter = counter + 1
if b > (counter - 1) * 9:
Y.append(b - (counter - 1) * 9)
while len(Y) < a:
Z.append(0)
Y.reverse()
for i in range(len(Y)):
print(Y[i], end="")
print(" ", end="")
if b != 0:
counter = 1
while counter * 9 <= b:
Z.append(9)
counter = counter + 1
if b > (counter - 1) * 9:
Z.append(b - (counter - 1) * 9)
while len(Z) < a:
Z.append(0)
for i in range(len(Z)):
print(Z[i], end="") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING IF VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def get_largest(special, length_digits):
actual_digits = len(special)
return special + [0] * (length_digits - actual_digits)
def get_smallest(special, length_digits):
reversed_special = special[::-1]
actual_digits = len(reversed_special)
if length_digits == actual_digits:
return reversed_special
reversed_special[0] -= 1
return [1] + [0] * (length_digits - actual_digits - 1) + reversed_special
def get_special(length_digits, sum_digits):
digits_needed = sum_digits // 9
last_digit = sum_digits % 9
if last_digit > 0:
digits_needed += 1
else:
last_digit = 9
if length_digits < digits_needed:
return -1
special = [9] * (digits_needed - 1) + [last_digit]
return special
def solve(length_digits, sum_digits):
if sum_digits == 0 and length_digits == 1:
return "0", "0"
if sum_digits <= 0 and length_digits > 1:
return "-1", "-1"
special = get_special(length_digits, sum_digits)
if special == -1:
return "-1", "-1"
smallest = get_smallest(special, length_digits)
largest = get_largest(special, length_digits)
s1 = [str(i) for i in smallest]
res1 = int("".join(s1))
s2 = [str(i) for i in largest]
res2 = int("".join(s2))
return res1, res2
m, s = [int(x) for x in input().split()]
solution = solve(m, s)
print(solution[0], solution[1]) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST VAR RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING STRING IF VAR NUMBER VAR NUMBER RETURN STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER RETURN STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s < 10 and m == 1:
print(s, s)
elif s == 0 and m > 1:
print("-1", "-1")
elif s > 9 * m:
print("-1", "-1")
else:
t = s
x = 0
a = 0
while t > 8:
x = x + 9 * 10 ** (m - a - 1)
t = t - 9
a = a + 1
if t > 0:
x = x + t * 10 ** (m - a - 1)
y = 0
if s < 10:
y = 10 ** (m - 1) + s - 1
elif s <= 9 * (m - 1) + 1:
if (s - 1) % 9 > 0:
y = (
10 ** (m - 1)
+ ((s - 1) % 9 + 1) * 10 ** int((s - 1 - (s - 1) % 9) / 9)
- 1
)
else:
y = 10 ** (m - 1) + 10 ** ((s - 1) // 9) - 1
else:
y = (s - 9 * m + 10) * 10 ** (m - 1) - 1
print(y, x) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP 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_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
M, S = m, s
if s == 0 and m == 1:
print(0, 0)
exit()
if s > 9 * m or s == 0:
print(-1, -1)
exit()
mn = [0] * m
mx = [0] * m
mn[0] = 1
s -= 1
i = m - 1
while s >= 10:
mn[i] = 9
s -= 9
i -= 1
mn[i] += s
i = 0
while S >= 10:
mx[i] = 9
S -= 9
i += 1
mx[i] += S
print(int("".join(map(str, mn))), int("".join(map(str, mx)))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | msStr = input()
mStr = msStr.split()[0]
sStr = msStr.split()[1]
m = int(mStr)
s = int(sStr)
if s == 0 and m > 1 or s > 9 * m:
print("-1 -1")
quit()
def digList2Num(digList):
size = len(digList)
sum = 0
for i in range(size):
sum = sum + digList[i] * 10 ** (size - 1 - i)
return sum
maxList = list()
for i in range(m):
if s > 9:
maxList.append(9)
s = s - 9
else:
maxList.append(s)
s = 0
maxNum = digList2Num(maxList)
minList = maxList
minList.reverse()
if minList[0] == 0:
for i in range(m):
if minList[i] != 0:
minList[0] = minList[0] + 1
minList[i] = minList[i] - 1
break
minNum = digList2Num(minList)
print(minNum, maxNum) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER 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 EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, k = map(int, input().split())
if n > 1 and k == 0 or k > 9 * n:
print("-1 -1")
if n > 1 and k != 0 and k <= 9 * n:
m = k
s1 = ""
for i in range(n):
if m >= 9:
s1 += "9"
m -= 9
else:
s1 += str(m)
m = 0
c = "1"
i = n + 1
for j in range(n):
if s1[j] == "0" and i > n:
i = j
if i < n:
s = s1[0 : i - 1] + str(int(s1[i - 1]) - 1) + s1[i : n - 1] + "1"
else:
s = s1
s = s[::-1]
print(s + " " + s1)
if n == 1 and k < 10:
print(k, k) | 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 VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR IF VAR NUMBER VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | a = input().split()
b = int(a[0])
c = int(a[1])
c1 = c
l1 = []
l2 = []
if c == 0 and b != 1:
print("-1 -1")
elif c > b * 9:
print("-1 -1")
else:
d = 0
for i in range(b):
c -= 9
if c >= 0:
d += 1
else:
break
if c == 0:
for i in range(b):
l1.append(str(9))
else:
e = c + 9
f = b - d - 1
for i in range(d):
l1.append(str(9))
l1.append(str(e))
for i in range(f):
l1.append(str(0))
g = c1 - 1
h = 0
for i in range(b - 1):
g -= 9
if g >= 0:
h += 1
else:
break
i = c1 - 9 * h
if h == b - 1:
l2.append(str(i))
for i in range(b - 1):
l2.append(str(9))
else:
l2.append(str(1))
j = b - h - 1
for i in range(j - 1):
l2.append(str(0))
l2.append(str(c1 - 9 * h - 1))
for i in range(h):
l2.append(str(9))
print("".join(l2) + " " + "".join(l1)) | 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 LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL STRING VAR STRING FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def findMin(m, s):
vals = [0] * m
for index in range(m - 1, -1, -1):
if s <= 9:
if s > 0:
vals[index] = s - 1
vals[0] = vals[0] + 1
else:
vals[index] = max(0, vals[index])
s = 0
else:
vals[index] = 9
s = s - 9
vals = [str(x) for x in vals]
return vals
def findMax(m, s):
vals = [0] * m
for index in range(0, m):
if s <= 9:
vals[index] = s
s = 0
else:
vals[index] = 9
s = s - 9
vals = [str(x) for x in vals]
return vals
m, s = [int(x) for x in input().split()]
if m * 9 < s:
print("-1 -1")
elif m > 1 and s == 0:
print("-1 -1")
else:
min_val = "".join(findMin(m, s))
max_val = "".join(findMax(m, s))
print("{} {}".format(int(min_val), int(max_val))) | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(i) for i in input().split()]
if s == 0 and m > 1 or s > 9 * m:
print("-1", "-1")
exit()
maxn = 0
k = s
for i in range(m):
if i < m - 1 and k >= 10 or i == m - 1 and k == 9:
maxn += 9 * 10**i
k -= 9
elif i < m - 1:
maxn += (k - 1) * 10**i
k -= k - 1
else:
maxn += k * 10**i
print(maxn, end=" ")
minn = 0
for j in range(m - 1, -1, -1):
if s >= 9:
minn += 9 * 10**j
s -= 9
else:
minn += s * 10**j
s = 0
print(minn, end=" ") | 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 STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(x) for x in input().split()]
r = ""
rx = ""
if m == 1 and s == 0:
print(0, 0)
elif s == 0 or s > 9 * m:
print(-1, -1)
elif m == 1:
print(s, s)
elif s < 10:
print("1" + "0" * (m - 2) + str(s - 1), str(s) + "0" * (m - 1))
elif s == m * 9:
print("9" * m, "9" * m)
else:
for i in range(1000):
r += "9"
s -= 9
if s <= 9:
break
rx = r
r += str(s)
if len(r) < m:
r += "0" * (m - len(r))
if len(rx) < m - 1:
rx = "1" + (m - len(rx) - 2) * "0" + str(s - 1) + rx
else:
rx = str(s) + rx
print(rx, r) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | R = lambda: map(int, input().split())
l, s = R()
ss = (str(s % 9) if s % 9 else "") + "9" * (s // 9)
if not ss:
print("-1 -1" if l > 1 else "0 0")
exit(0)
if len(ss) > l:
print("-1 -1")
else:
if len(ss) < l:
if ss[0] > "1":
smi = "1" + "0" * (l - len(ss) - 1) + str(int(ss[0]) - 1) + ss[1:]
else:
smi = ss[0] + "0" * (l - len(ss)) + ss[1:]
smx = ss[::-1] + "0" * (l - len(ss))
else:
smi = ss
smx = ss[::-1]
print(smi, smx, sep=" ") | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR NUMBER STRING STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def majmo(x):
x = str(x)
sum = 0
for i in range(len(x)):
sum += int(x[i])
return sum
n, m = map(int, input().split())
if m != 0 and m <= n * 9:
if 9 * (n - 1) < m <= 9 * n:
if n != 1:
minn = 10 ** (n - 1)
maxx = 10**n - 1
r = 0
while majmo(minn) < m:
minn += 9 * 10**r
r += 1
if r == n - 1:
break
if majmo(minn) < m:
minn += (m - majmo(minn)) * 10**r
u = 0
while majmo(maxx) > m:
maxx -= 9 * 10**u
u += 1
if u == n - 1:
break
if majmo(maxx) < m:
maxx += (m - majmo(maxx)) * 10 ** (u - 1)
if m != 0:
print(minn, maxx)
else:
print(m, m)
else:
minn = 10 ** (n - 1)
maxx = 10**n - 1
r = 0
while majmo(minn) < m:
minn += 9 * 10**r
r += 1
if majmo(minn) > m:
minn -= (majmo(minn) - m) * 10 ** (r - 1)
u = 0
while majmo(maxx) > m:
maxx -= 9 * 10**u
u += 1
if majmo(maxx) < m:
maxx += (m - majmo(maxx)) * 10 ** (u - 1)
if m != 0:
print(minn, maxx)
elif m == 0 and n == 1:
print(0, 0)
elif m > n * 9:
print(-1, -1)
else:
print(-1, -1) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
l = [1]
for i in range(m - 1):
l.append(0)
if m == 1 and s == 0:
print(0, 0)
elif s == 0 or s > 9 * m:
print(-1, -1)
else:
x = s
s -= 1
for i in range(len(l) - 1, -1, -1):
l[i] += min(9, s)
s -= min(9, s)
z = [0] * m
for i in range(m):
z[i] = min(9, x)
x -= min(9, x)
a, b = "", ""
for i in range(len(l)):
a += str(l[i])
b += str(z[i])
print(a, b) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | x = input().split()
m = int(x[0])
s = int(x[1])
if s == 0:
if m == 1:
print("0 0")
else:
print("-1 -1")
elif s > m * 9:
print("-1 -1")
else:
s1 = s
maxlist = []
for i in range(m):
num = min(9, s1)
maxlist.append(num)
s1 -= num
maxint = 0
for i in range(len(maxlist)):
maxint += maxlist[i] * 10 ** (len(maxlist) - 1 - i)
if maxlist[len(maxlist) - 1] == 0:
maxlist[len(maxlist) - 1] = 1
for i in range(len(maxlist) - 2, -1, -1):
if maxlist[i] != 0:
maxlist[i] -= 1
break
minint = 0
for i in range(len(maxlist)):
minint += maxlist[i] * 10**i
print(minint, maxint) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if m == 1 and s <= 9:
print(s, s)
elif s == 0 or s > 9 * m:
print("-1 -1")
else:
n_9 = s // 9
yu = s % 9
if n_9 == m:
print(m * "9", m * "9")
elif n_9 == m - 1:
if yu == 0:
print("18" + (n_9 - 1) * "9", n_9 * "9" + str(yu))
else:
print(str(yu) + n_9 * "9", n_9 * "9" + str(yu))
elif yu == 0:
print(
"1" + "0" * (m - 1 - n_9) + "8" + (n_9 - 1) * "9",
n_9 * "9" + (m - n_9) * "0",
)
else:
print(
"1" + "0" * (m - 2 - n_9) + str(yu - 1) + n_9 * "9",
n_9 * "9" + str(yu) + (m - n_9 - 1) * "0",
) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING BIN_OP VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR STRING BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR STRING BIN_OP BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR STRING BIN_OP BIN_OP VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR STRING BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | M, S = map(int, input().split())
if S == 0 and M == 1:
print("0 0")
exit()
elif S == 0 or M * 9 < S:
print("-1 -1")
exit()
m, s = M, S
l = []
if s <= (m - 1) * 9 + 1:
l.append(1)
s -= 1
while len(l) < m:
r = (m - len(l) - 1) * 9
if s <= r:
l.append(0)
else:
l.append(s - r)
s -= s - r
m, s = M, S
h = []
while s >= 9:
h.append(9)
s -= 9
while len(h) < m:
h.append(s)
s = 0
print("".join(repr(x) for x in l), "".join(repr(x) for x in h)) | 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 NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST IF VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_CALL STRING FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def ma(a, b):
ans = ""
for a in range(a):
ans += str(min(9, b))
b -= min(9, b)
return ans
a, b = map(int, input().split())
if b == 0 or b > 9 * a:
if b:
print(-1, -1)
elif a == 1:
print(0, 0)
else:
print(-1, -1)
else:
q = ma(a, b)
mi = q[::-1]
if mi[0] != "0":
print(mi, q)
else:
print("1" + ma(a - 1, b - 1)[::-1], q) | FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
res = ""
if m == 1 and s == 0:
print(0, 0)
elif m * 9 < s or s < 1:
print(-1, -1)
elif m > 1:
if s <= 10:
res = "1" + "0" * (m - 2) + str(s - 1)
elif 0 <= s - (m - 1) * 9 <= 9:
res = str(s - (m - 1) * 9) + "9" * (m - 1)
else:
res = (
"1"
+ (m - 2 - (s - 1) // 9) * "0"
+ str(s - 1 - int((s - 1) // 9) * 9)
+ (s - 1) // 9 * "9"
)
print(res, end=" ")
if s <= 9:
print(str(s) + (m - 1) * "0")
elif s % 9 == 0:
print("9" * (s // 9) + "0" * (m - s // 9))
else:
print("9" * (s // 9) + str(s % 9) + "0" * (m - 1 - s // 9))
else:
print(s, s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING 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 IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER IF NUMBER BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER STRING FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def find_max_min(m, s):
if m == 1:
if s < 10:
return [str(s), str(s)]
else:
return ["-1", "-1"]
if m > 1:
if s < 10:
mini = "1" + "0" * (m - 2) + "{}".format(s - 1)
maxm = "{}".format(s) + "0" * (m - 1)
return [mini, maxm]
if s >= 10:
mini, maxm = find_max_min(m - 1, s - 9)
return [mini + "9", "9" + maxm]
m, s = map(int, input().split())
if s == 0:
if m == 1:
print("0 0")
else:
print("-1 -1")
else:
x = find_max_min(m, s)
if x[0][0] == "-" or s == 0:
print("-1 -1")
else:
print("{} {}".format(x[0], x[1])) | FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN LIST STRING STRING IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL STRING VAR BIN_OP STRING BIN_OP VAR NUMBER RETURN LIST VAR VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN LIST BIN_OP VAR STRING BIN_OP STRING VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n1 = input().split()
n = int(n1[0])
s = int(n1[1])
if s > 0 and n * 9 > s:
m = int(s / 9)
my = s % 9
d = n - 1 - m
j = " "
for i in range(m):
j += "9"
j += str(my)
for i in range(d):
j += "0"
if d == 0:
for i in range(m):
j = "9" + j
j = str(my) + j
elif my > 0:
my -= 1
for i in range(m):
j = "9" + j
j = str(my) + j
for i in range(d - 1):
j = "0" + j
j = "1" + j
else:
my = 8
for i in range(m - 1):
j = "9" + j
j = str(my) + j
for i in range(d):
j = "0" + j
j = "1" + j
print(j)
elif n * 9 < s:
print("-1 -1")
elif s == 0:
if n == 1:
print("0 0")
else:
print("-1 -1")
else:
j = " "
for i in range(n):
j = "9" + j + "9"
print(j) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR STRING EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def solve():
m, s = map(int, input().strip().split())
if s > 9 * m:
print(-1, -1)
elif m == 1 and s == 0:
print(0, 0)
elif s == 0:
print(-1, -1)
else:
lar = [0] * m
sm = [0] * m
sl = s
i = 0
while sl != 0:
if sl >= 9:
lar[i] = lar[i] + 9
sl -= 9
i += 1
else:
lar[i] += sl
sl = 0
sm[0] = 1
s -= 1
i = m - 1
while s != 0:
if s >= 9:
sm[i] += 9
s -= 9
i -= 1
else:
sm[i] += s
s = 0
sm = "".join(map(str, sm))
lar = "".join(map(str, lar))
if int(sm) >= 10 ** (m - 1) and int(lar) >= 10 ** (m - 1):
print(sm, lar)
else:
print(-1, -1)
solve() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | a, b = [int(i) for i in input().split()]
a1 = a2 = a
b1 = b2 = b
if 9 * a < b:
print("-1 -1")
elif b == 0:
if a == 1:
print("0", "0")
else:
print("-1 -1")
else:
d = ""
e = ""
while a1 > 0:
c = b1
if c >= 9:
c = 9
d += str(c)
a1 -= 1
b1 -= c
while a2 > 0:
c = b2 - 9 * a2 + 9
if c < 1:
if e == "":
c = 1
else:
c = 0
e += str(c)
a2 -= 1
b2 -= c
print(e, d) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER IF VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
dp_max = [([0] * (s + 1)) for i in range(m + 1)]
dp_min = [([-1] * (s + 1)) for i in range(m + 1)]
for i in range(1, min(10, s + 1)):
dp_min[1][i] = i
dp_max[1][i] = i
for i in range(2, m + 1):
for j in range(s + 1):
for d in range(10):
if j - d >= 0:
dp_max[i][j] = max(dp_max[i][j], dp_max[i - 1][j - d] * 10 + d)
if dp_min[i - 1][j - d] != -1:
if dp_min[i][j] == -1:
dp_min[i][j] = dp_min[i - 1][j - d] * 10 + d
dp_min[i][j] = min(dp_min[i][j], dp_min[i - 1][j - d] * 10 + d)
dp_max[1][0] = 0
dp_min[1][0] = 0
if dp_min[m][s] == -1:
print(-1, -1)
else:
print(dp_min[m][s], dp_max[m][s]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
c9 = 0
td = 0
flag = 0
if m == 1 and s == 0:
print(s, end=" ")
print(s)
elif s > m * 9 or s < 1:
print("-1 -1")
elif m == 1:
print(s, end=" ")
print(s)
else:
while s >= 9:
s -= 9
c9 += 1
if c9 == m and s == 0:
print("9" * m, end=" ")
print("9" * m)
flag = 1
elif s != 0:
td += 1
else:
c9 -= 1
s = 9
if flag == 0:
td += c9
minx = ""
maxx = ""
minx = "9" * c9
if td == m:
minx = str(s) + minx
else:
minx = str(s - 1) + minx
s0 = "0" * (m - c9 - 2)
minx = s0 + minx
minx = "1" + minx
maxx = "9" * c9
s0 = "0" * (m - c9 - 1)
maxx = maxx + str(s) + s0
print(minx, end=" ")
print(maxx) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP STRING VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | x = input().split()
a = int(x[0])
b = int(x[1])
v = b
v2 = b
v1 = a
if a == 1 and b == 0:
print(f"{0} {0}")
elif b == 0:
print(f"{-1} {-1}")
else:
emon = []
b = v2
while v2:
if b >= 9:
b = b - 9
emon.append(9)
elif b >= 8:
b = b - 8
emon.append(8)
elif b >= 7:
b = b - 7
emon.append(7)
elif b >= 6:
b = b - 6
emon.append(6)
elif b >= 5:
b = b - 5
emon.append(5)
elif b >= 4:
b = b - 4
emon.append(4)
elif b >= 3:
b = b - 3
emon.append(3)
elif b >= 2:
b = b - 2
emon.append(2)
elif b >= 1:
b = b - 1
emon.append(1)
if b == 0:
break
if len(emon) > a:
print(f"{-1} {-1}")
else:
g = 0
z = []
if len(emon) < a:
g = a - len(emon)
for i in range(g):
h = 0
z.append(h)
x = emon.copy()
y = x[::-1]
f = y[0]
f1 = y[0]
y.remove(f)
a1 = 0
if int(f) > 1:
z.remove(0)
a1 = int(f) - 1
f = 1
f = str(f)
p = "".join(str(m) for m in x)
r = "".join(str(x) for x in y)
q = "".join(str(x) for x in z)
if a1 != 0:
le1 = len(f + q + str(a1) + r)
if le1 == v1:
t = int(f + q + str(a1) + r)
else:
t = int(str(f1) + q + r)
else:
t = int(f + q + r)
le = len(f + q + r)
w = 1
for i in range(le - 1):
w = w * 10
sum = 0
if t == int(p + q):
for i in range(w, int(p + q)):
f = list(str(i))
for j in f:
sum = sum + int(j)
if sum == v:
t = i
break
sum = 0
if len(p + q) < v1:
q = q + str("0")
print(f"{t} {p + q}")
elif len(emon) == a:
m = emon.copy()
y = m[::-1]
m = "".join(str(x) for x in m)
y = "".join(str(x) for x in y)
print(f"{y} {m}") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR STRING BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | [m, s] = [int(i) for i in input().split()]
if s > 9 * m or m != 1 and s == 0:
print(-1, -1)
elif m == 1 and s == 0:
print(0, 0)
else:
max1 = min1 = 0
if s <= 9:
if not m == 1:
max1 = str(s) + (m - 1) * "0"
min1 = "1" + (m - 2) * "0" + str(s - 1)
else:
max1 = min1 = str(s)
else:
bit = s // 9
if s != bit * 9:
max1 = bit * "9" + str(s - 9 * bit) + (m - bit - 1) * "0"
if m - bit - 1 == 0:
min1 = str(s - 9 * bit) + bit * "9"
else:
min1 = "1" + (m - bit - 2) * "0" + str(s - 9 * bit - 1) + bit * "9"
elif m == bit:
max1 = min1 = bit * "9"
else:
max1 = bit * "9" + (m - bit) * "0"
min1 = "1" + (m - bit - 1) * "0" + "8" + (bit - 1) * "9"
print(min1, max1) | ASSIGN LIST 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER BIN_OP VAR STRING IF VAR VAR ASSIGN VAR VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP BIN_OP VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING STRING BIN_OP BIN_OP VAR NUMBER STRING EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | from sys import stdin
n, k = map(int, stdin.readline().rstrip().split(" "))
minimum = 1
maximum = n * 9
if k == 0 and n == 1:
print(0, 0)
elif k > maximum or k < minimum:
print(-1, -1)
elif k == maximum:
print("9" * n, "9" * n)
elif k == minimum:
print("1" + "0" * (n - 1), "1" + "0" * (n - 1))
else:
x = k // 9
xtr = k % 9
if xtr:
r = "9" * x
else:
r = "9" * (x - 1) + "8"
left = n - x
if left >= 1 and xtr:
if left > 1:
r += str(xtr - 1)
else:
r += str(xtr)
left -= 1
if left > 1:
r += "0" * (left - 1)
if left:
r += "1"
print(r[::-1], end=" ")
r2 = "9" * x + str(xtr)
if n - x - 1:
r2 += "0" * (n - x - 1)
print(r2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR IF VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP STRING BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if m == 1 and s == 0:
print("0 0")
exit()
if s >= 1 and s <= 9 * m:
mn = []
mx = []
for i in range(m):
mn.append(0)
mx.append(0)
mnk = s * 1
mxk = s * 1
mn[0] = 1
mnk -= 1
for i in range(m - 1, -1, -1):
if mnk > 9:
mn[i] += 9
mnk -= 9
else:
mn[i] += mnk
mnk = 0
break
mx[0] = min(mxk, 9)
mxk -= min(mxk, 9)
for i in range(1, m, 1):
if mxk > 9:
mx[i] += 9
mxk -= 9
else:
mx[i] += mxk
mxk = 0
break
a = []
b = []
for i in range(m):
a.append(str(mn[i]))
b.append(str(mx[i]))
print("".join(a), "".join(b))
else:
print("-1 -1") | 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 NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL STRING VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def small(m, s):
if s == 0:
if m == 1:
return 0
else:
return -1
if s > 9 * m:
return -1
res = [(0) for i in range(m)]
s -= 1
for i in range(m - 1, 0, -1):
if s > 9:
res[i] = 9
s -= 9
else:
res[i] = s
s = 0
res[0] = s + 1
s = ""
for i in res:
s += str(i)
return s
def large(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
s = ""
for i in res:
s += str(i)
return s
a, b = map(int, input().split())
print(small(a, b), large(a, b)) | FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR BIN_OP NUMBER VAR RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR 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 VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(i) for i in input().split()]
if m * 9 >= s and s > 0:
if m > s // 9 + 1:
print("1", end="")
k = m - ((s - 1) // 9 + 2)
if k >= 0:
for i in range(k):
print("0", end="")
print((s - 1) % 9, end="")
else:
pass
for i in range(m - k - 2):
print("9", end="")
print(" ", end="")
while m > 0:
if s > 9:
print("9", end="")
s = s - 9
m -= 1
elif s > 0:
print(s, end="")
s = 0
m -= 1
else:
print("0", end="")
m -= 1
elif m == s // 9 + 1:
print(s % 9, end="")
for i in range(s // 9):
print("9", end="")
print(" ", end="")
for i in range(s // 9):
print("9", end="")
print(s % 9, end="")
else:
for i in range(s // 9):
print("9", end="")
print(" ", end="")
for i in range(s // 9):
print("9", end="")
elif m == 1 and s == 0:
print("0 0")
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING STRING WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = (int(x) for x in input().split())
if s == 0:
print("0 0" if m == 1 else "-1 -1")
elif s > m * 9:
print("-1 -1")
else:
maxs = "9" * (s // 9) + (str(s % 9) if s % 9 else "") + "0" * (m - (s + 8) // 9)
mins = maxs[::-1]
if mins[0] == "0":
nzi = mins.index(next(ch for ch in mins if ch != "0"))
mins = "1" + mins[1:nzi] + str(int(mins[nzi]) - 1) + mins[nzi + 1 :]
print(mins, maxs) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | line = input()
L = line.split()
i = 0
s1 = ""
s2 = ""
n = int(L[0])
m = int(L[1])
if n == 1 and m == 0:
print("0 0")
elif m == 0 or m > 9 * n:
print("-1 -1")
else:
m1 = 9 * n - m
m2 = m
for i in range(n):
if i == 0:
t = min(8, m1)
else:
t = min(9, m1)
s1 += str(9 - t)
m1 -= t
u = min(9, m2)
s2 += str(u)
m2 -= u
print(s1, s2) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN 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 STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def functoin():
a = [0] * 105
m, s = map(int, input().split())
if not s:
if m == 1:
print("0 0")
else:
print("-1 -1")
return
for x in range(1, 10):
tmp = s - x
for j in range(m - 1, 0, -1):
if tmp >= 9:
a[j] = 9
tmp -= 9
else:
a[j] = tmp
tmp = 0
if tmp == 0:
a[0] = x
break
if not a[0]:
print("-1 -1")
return
for x in range(m):
print(a[x], end="")
print(" ")
for x in range(m):
if s >= 9:
print(9, end="")
s -= 9
else:
print(s, end="")
s = 0
functoin() | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def solve(m, s):
if s == 0:
return (0, 0) if m == 1 else (-1, -1)
if s > 9 * m:
return -1, -1
if s == 1:
return "1" + "0" * (m - 1), "1" + "0" * (m - 1)
maxnum = []
while s > 9:
maxnum.append("9")
s -= 9
maxnum.append(str(s))
n = len(maxnum)
maxnum.extend(["0" for i in range(m - n)])
minnum = list(reversed(maxnum))
if m > n:
minnum[0] = "1"
if s > 0:
minnum[-n] = str(s - 1)
else:
minnum[-n - 1] = str("8")
return "".join(minnum), "".join(maxnum)
m, s = [int(x) for x in input().split()]
ans = solve(m, s)
print(ans[0], ans[1]) | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR BIN_OP NUMBER VAR RETURN NUMBER NUMBER IF VAR NUMBER RETURN BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING RETURN FUNC_CALL STRING VAR FUNC_CALL STRING VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | l, s = map(int, input().split())
if l == 1 and s == 0:
print(0, 0)
elif l * 9 < s or s == 0:
print(-1, -1)
else:
s1 = s
mx = ""
while s1 != 0:
if s1 > 9:
mx = mx + "9"
s1 -= 9
else:
mx = mx + str(s1)
s1 = 0
else:
leng = len(mx)
if leng != l:
mx = mx + "0" * (l - leng)
s1 = s - 1
mn = ""
while s1 != 0:
if s1 > 9:
mn = mn + "9"
s1 -= 9
else:
mn = mn + str(s1)
s1 = 0
else:
mn = "1" + "0" * (l - 1 - len(mn)) + mn[:][::-1]
if len(mn) > l:
mn = str(int(mn[0]) + int(mn[1])) + mn[2:]
print(mn, mx) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 ASSIGN VAR VAR ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | d, n = map(int, input().split())
maxa = [0] * d
mina = [0] * d
m = n
if n / d > 9 or n / d == 0:
if d == 1 and n == 0:
print(0, 0)
else:
print(-1, -1)
else:
for i in range(d):
k = 9
while True:
if n - k >= 0:
maxa[i] = str(k)
n -= k
break
else:
k -= 1
for i in range(d):
if i == 0:
k = 1
else:
k = 0
while True:
if m - k <= 9 * (d - 1 - i):
mina[i] = str(k)
m -= k
break
else:
k += 1
print("".join(mina), "".join(maxa)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | import sys
cache = {}
def logging(fun):
def decorated(*args):
result = fun(*args)
print(fun.__name__, args, " -> ", result)
return result
return decorated
def num(m, s):
if m < 1:
return -1, -1
if m == 1:
if s in range(1, 10):
return s, s
else:
return -1, -1
if (m, s) in cache:
return cache[m, s]
result_min, result_max = -1, -1
for d in range(0, 10):
prev_min, prev_max = num(m - 1, s - d)
if prev_min < 0:
continue
prev_min = prev_min * 10 + d
prev_max = prev_max * 10 + d
if result_min == -1:
result_min, result_max = prev_min, prev_max
else:
result_min = min(result_min, prev_min)
result_max = max(result_max, prev_max)
cache[m, s] = result_min, result_max
return result_min, result_max
m, s = map(int, input().split())
if m == 1 and s == 0:
print("0 0")
else:
print(" ".join(map(str, num(m, s)))) | IMPORT ASSIGN VAR DICT FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING VAR RETURN VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER NUMBER IF VAR NUMBER IF VAR FUNC_CALL VAR NUMBER NUMBER RETURN VAR VAR RETURN NUMBER NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = list(map(int, input().split()))
if s == 0:
print("-1 -1") if m > 1 else print("0 0")
exit()
ma = [0] * m
mi = [0] * m
ss = s - 1
for i in range(m):
if s <= 0:
break
ma[i] = 9 if s > 9 else s
s -= ma[i]
if s > 0:
print("-1 -1")
exit()
mi[0] = 1
for i in range(m - 1, -1, -1):
if ss <= 0:
break
mi[i] += 9 if ss > 9 else ss
ss -= mi[i]
for i in range(m):
print(mi[i], end="")
print(" ", end="")
for i in range(m):
print(ma[i], end="") | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR VAR NUMBER NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s / m > 9:
maxim = -1
elif s == 0 and m > 1:
maxim = -1
else:
maxim = ""
s_dup = s
while s_dup > 0:
if s_dup >= 9:
s_dup -= 9
maxim += "9"
else:
maxim += str(s_dup)
s_dup = 0
while len(maxim) < m:
maxim += "0"
if s == 0 and m > 1:
minim_ans = -1
elif s / m > 9:
minim_ans = -1
elif s == 0:
minim_ans = 0
else:
first_digit = s - (m - 1) * 9
if first_digit <= 0:
first_digit = 1
minim = [first_digit]
s_dup = s - first_digit
while s_dup > 0:
if s_dup >= 9:
s_dup -= 9
minim.append(9)
else:
minim.insert(1, s_dup)
s_dup = 0
while len(minim) < m:
minim.insert(1, 0)
minim_ans = ""
for i in minim:
minim_ans += str(i)
print(minim_ans, maxim) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | q = str(input())
q = q.split()
m = int(q[0])
s = int(q[1])
if s == 0 and m != 1 or s > 9 * m:
s = -1
s_ = s
L = []
if s != 0:
L.append(1)
for i in range(m - 1):
L.append(0)
else:
for i in range(m):
L.append(0)
x = 1
while s_ > 1:
d = L[len(L) - x]
while s_ != 1 and d != 9:
d += 1
s_ -= 1
L[len(L) - x] = d
x += 1
mini = ""
for i in range(m):
mini += str(L[i])
s_ = s
L = []
for i in range(m):
L.append(0)
x = 0
while s_ > 0:
d = L[x]
while s_ != 0 and d != 9:
d += 1
s_ -= 1
L[x] = d
x += 1
maxi = ""
for i in range(m):
maxi += str(L[i])
if s == -1:
print("-1 -1")
else:
print(mini + " " + maxi) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, m = tuple(map(int, input().split()))
if m == 0:
if n == 0 or n > 1:
print(-1, -1)
else:
print(0, 0)
elif 9 * n < m:
print(-1, -1)
elif n == 0 and m > 1:
print(-1, -1)
else:
mare = ""
mic = ""
cn = n
cm = m
while cn or cm:
if cm:
if cm > 9:
mare += "9"
cm -= 9
else:
mare += str(cm)
cm = 0
else:
mare += "0"
cn -= 1
mic = list(mare[::-1])
mic = [i for i in mic if i != "0"]
g = n - len(mic)
mici = ""
if g == 0:
for i in mic:
mici += i
else:
mici += "1"
g -= 1
mic[0] = str(int(mic[0]) - 1)
while g:
g -= 1
mici += "0"
for i in mic:
mici += i
print(mici, mare) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR NUMBER FOR VAR VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR VAR NUMBER VAR STRING FOR VAR VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | inputlist = list(map(int, input().split()))
m = inputlist[0]
s = inputlist[1]
stop = False
if s == 0 and m != 1:
print("-1 -1")
stop = True
elif s == 0 and m == 1:
print("0 0")
stop = True
elif s > 9 * m:
print("-1 -1")
stop = True
else:
max = ""
steps = 0
while steps != m and stop == False:
if s >= 9:
max += "9"
s -= 9
else:
max += str(s)
for j in range(m - steps - 1):
max += str(0)
break
steps += 1
max = int(max)
s = inputlist[1]
min = ""
j = 1
while 9 * m < s - j + 9 and stop == False:
j += 1
min += str(j)
m -= 1
s -= j
k = m
for i in range(m):
j = 0
while 9 * k < s - j + 9:
j += 1
min += str(j)
s -= j
k -= 1
print(min, max) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, m = map(int, input().split())
def smal(n, m):
first = m % 9
no9 = m // 9
if no9 < n - 1:
if not first:
first = 9
no9 -= 1
ans = "1" + "0" * (n - no9 - 2) + str(first - 1) + "9" * no9
elif no9 == n - 1:
if not first:
ans = "18" + "9" * (n - 2)
else:
ans = str(first) + "9" * (n - 1)
else:
ans = "9" * no9
return ans
def big(n, m):
last = m % 9
no9 = m // 9
ans = "9" * no9 + str(last) + "0" * (n - no9 - 1)
return ans[:n]
if m > 9 * n:
print("-1 -1")
elif m < 1:
if n == 1:
print("0 0")
else:
print("-1 -1")
else:
print(smal(n, m), big(n, m)) | 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 BIN_OP VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING VAR IF VAR BIN_OP VAR NUMBER IF VAR ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | inp = list(map(int, input().split()))
big = inp[0]
tot = inp[1]
maxi = []
mini = []
for i in range(big):
maxi.append(0)
mini.append(0)
maxi[0] = 1
mini[0] = 1
sumax = 1
lasti = 0
sumin = 1
if 9 * big < tot or tot < 1 and big > 1:
print("-1 -1")
elif big == 1 and tot == 0:
print("0 0")
else:
while sumax < tot:
if maxi[lasti] < 9:
maxi[lasti] += 1
sumax += 1
else:
lasti += 1
maxi[lasti] += 1
sumax += 1
lasti = big - 1
while sumin < tot:
if mini[lasti] < 9:
mini[lasti] += 1
sumin += 1
else:
lasti -= 1
mini[lasti] += 1
sumin += 1
for i in range(big):
print(mini[i], end="")
print("", end=" ")
for i in range(len(maxi)):
print(maxi[i], end="") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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 WHILE VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def find(step):
if m == 1 and s == 0:
return 0
ss = s
res = ""
for i in range(m):
j = 1 if i == 0 else 0
ok = False
c = list(range(j, 10)) if step == -1 else reversed(list(range(j, 10)))
for v in c:
if 0 <= ss - v <= (m - i - 1) * 9:
ok = True
ss -= v
res += str(v)
break
if not ok:
return -1
return res
m, s = list(map(int, input().split()))
print(find(-1), find(1)) | FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF NUMBER BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR IF VAR RETURN NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | line = input()
m = int(line.split()[0])
s = int(line.split()[1])
if s == 0 and m != 1 or s > 9 * m:
print("-1 -1")
elif s == 0 and m == 1:
print("0 0")
else:
k = 0
while s > 9:
s = s - 9
k += 1
i = 0
maxs = 0
t = m
while i < k:
maxs += 9 * 10 ** (t - 1)
i += 1
t -= 1
maxs += s * 10 ** (t - 1)
mins = 0
j = 0
while j < k:
mins += 9 * 10**j
j += 1
mins += 10 ** (m - 1) + (s - 1) * 10**k
print(str(mins) + " " + str(maxs)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER 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 NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | import sys
input = sys.stdin.readline
m, s = map(int, input().split())
if s == 0 or s > 9 * m:
if s == 0 and m == 1:
print(*[0, 0])
else:
print(*[-1, -1])
exit()
res = m * [0]
ress = m * [0]
res[0] = 1
ress[0] = 1
l = 0
r = m - 1
for i in range(1, s):
if res[l] == 9:
l += 1
res[l] += 1
if ress[r] == 9:
r -= 1
ress[r] += 1
for i in ress:
print(i, end="")
print(end=" ")
for i in res:
print(i, end="") | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
k = s
r = s
l = []
t = []
def max():
global k
global l
for i in range(0, m):
if k >= 9:
l.append(9)
k = k - 9
elif 1 <= k < 9:
l.append(k)
k = 0
else:
l.append(0)
l = int("".join(list(map(str, l))))
print(l)
def min():
global r
global t
for i in range(0, m):
if r == 0:
print(0)
if r > 9:
t.append(9)
r = r - 9
elif 1 < r <= 9 and i != m - 1:
t.append(r - 1)
r = 1
elif 1 < r <= 9 and i == m - 1:
t.append(r)
break
elif i == m - 1:
t.append(1)
else:
t.append(0)
t.reverse()
t = int("".join(list(map(str, t))))
print(t, end=" ")
if s > 9 * m:
print("-1", end=" ")
print("-1")
exit()
elif s == 0 and m == 1:
print(0, end=" ")
print(0)
elif s == 0:
print("-1", end=" ")
print("-1")
exit()
else:
min()
max() | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | p = input().split()
m = int(p[0])
s = int(p[1])
min = max = 0
if 9 * m < s:
print("-1 -1")
elif m == 1 and s == 0:
print("0 0")
elif m != 1 and s == 0:
print("-1 -1")
else:
a = s % 9
b = (s - a) / 9
for i in range(m):
if i < b:
min = min + 9 * 10**i
max = max + 9 * 10 ** (m - i - 1)
elif i == b:
max = max + a * 10 ** (m - i - 1)
if b == m - 1:
min = min + a * 10**i
elif a >= 1 and b < m - 1:
min = min + (a - 1) * 10**i
else:
min = min - 10 ** (i - 1)
if i == m - 1 and b < m - 1:
min = min + 10**i
print(min, max) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | a, b = map(int, input().split())
if b > 9 * a:
print("-1" + " " + "-1")
elif b == 0 and a > 1:
print("-1" + " " + "-1")
elif a == 1 or b / a == 9:
print(str(b // a) * a + " " + str(b // a) * a)
else:
mx1 = b // 9
mx2 = b % 9
mx = mx1 * "9" + str(mx2) + (a - mx1 - 1) * "0"
my = mx
y = my.count("0")
if y == 0:
x = list(mx)
x.reverse()
mi = "".join(x)
else:
mi = "1" + (y - 1) * "0" + str(eval(mx[-y - 1]) - 1) + (a - y - 1) * "9"
print(mi + " " + mx) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING STRING STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING STRING STRING IF VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR STRING BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | l, s = map(int, input().split())
ma = 0
mi = 0
si = s - 1
maw = [9]
miw = [1] * l
if s == 0 and l != 1 or l == 0:
ma = -1
mi = -1
else:
if s <= 9:
ma = s * 10 ** (l - 1)
elif s > l * 9:
ma = -1
else:
ss = s - 9
for i in range(1, l):
if ss > 9:
maw.append(9)
ss -= 9
else:
maw.append(ss)
ss = 0
for i in range(l):
ma += 10 ** (l - i - 1) * maw[i]
if l == 1 and s <= 9:
mi = s
elif s == 1:
mi = 10 ** (l - 1)
elif s > l * 9:
mi = -1
elif l * 9 - 8 < s <= l * 9:
miw = [9] * l
miw[0] = s - 9 * (l - 1)
for i in range(l):
mi += 10 ** (l - 1 - i) * miw[i]
else:
for i in range(l):
if si > 9:
miw[l - 1 - i] = 9
si -= 9
elif si <= 9:
miw[l - 1 - i] = si
si = 0
miw[0] = 1
for i in range(l):
mi += 10 ** (l - 1 - i) * miw[i]
print(mi, ma) | 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 LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def main():
m, s = map(int, input().split())
if m == 1 and s == 0:
print(0, 0)
elif s > 9 * m or s == 0:
print(-1, -1)
else:
x = 10 ** (m - 1)
y = 0
for i in range(s - 1):
x = x + 10 ** (i // 9)
for i in range(s):
y = y + 10 ** (m - 1 - i // 9)
print(x, y)
main() | FUNC_DEF 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 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 EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, Sum = list(map(int, input().split()))
if n == 1 and Sum == 0:
print(0, 0)
elif Sum == 0 or Sum > 9 * n:
print(-1, -1)
else:
l = [0] * n
r = [0] * n
b, p = "", ""
s = Sum
for i in range(n):
if s >= 9:
r[i] = 9
s -= 9
else:
r[i] = s
s = 0
l[n - i - 1] = r[i]
if l[0] != 0:
for i in range(n):
b = b + str(l[i])
p = p + str(r[i])
print(b, p)
else:
for i in range(n):
if l[i] != 0:
break
l[0] = "1"
l[i] = l[i] - 1
for i in range(n):
b = b + str(l[i])
p = p + str(r[i])
print(b, p) | ASSIGN VAR VAR FUNC_CALL 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 BIN_OP LIST NUMBER VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER STRING ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, s = map(int, input().split())
if n == 1 and s == 0:
print("0 0")
elif s == 0 or 9 * n < s:
print("-1 -1")
elif n == 1:
print(s, s)
else:
p = s
h = ""
for i in range(n):
if p >= 9:
h += "9"
p -= 9
else:
h += str(p)
p -= p
q = s
l = ""
for i in range(n):
if q > 9:
l = "9" + l
q -= 9
elif i != n - 1 and q <= 9:
l = str(q - 1) + l
q = 1
elif i != n - 1 and q == 1:
l = str(0) + l
elif i == n - 1 and q <= 9:
l = str(q) + l
print(int(l), int(h)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | from sys import stdin
lines = list([_f for _f in stdin.read().split("\n") if _f])
def parseline(line):
return list(map(int, line.split()))
lines = list(map(parseline, lines))
m, s = lines[0]
if 9 * m < s or m > 1 and s == 0:
print("-1 -1")
return
if m == 1 and s == 0:
minimum = [0]
else:
minimum = []
s1 = s
while s1 > 0:
digit = min(9, s1)
minimum.append(digit)
s1 -= digit
if len(minimum) < m:
minimum[-1] -= 1
minimum += [0] * (m - len(minimum) - 1)
minimum.append(1)
minimum = "".join(map(str, reversed(minimum)))
maximum = []
s2 = s
while s2 > 0:
digit = min(9, s2)
maximum.append(digit)
s2 -= digit
maximum += [0] * (m - len(maximum))
maximum = "".join(map(str, maximum))
print(minimum, maximum) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | class killme(Exception):
@classmethod
def ssss(self):
print(-1, -1)
m, n = map(int, input().split())
try:
if 9 * m < n or n == 0 and m > 1:
raise killme()
else:
nine = n // 9
last = n % 9
if m == 1:
a = n
b = n
elif nine == m:
a = "9" * nine
b = a
elif nine + 1 == m:
a = "9" * nine + str(last)
b = a[::-1]
else:
a = "9" * nine + str(last) + "0" * (m - nine - 1)
if last > 0:
b = "1" + "0" * (m - 2 - nine) + str(last - 1) + "9" * nine
elif nine > 0:
b = "1" + "0" * (m - 1 - nine) + "8" + "9" * (nine - 1)
else:
b = "1" + "0" * (m - 2) + str(last - 1)
print(int(b), int(a))
except killme:
killme.ssss() | CLASS_DEF VAR FUNC_DEF EXPR FUNC_CALL VAR NUMBER NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | a, b = map(int, input().split())
min = ""
max = ""
ans = 0
s = b
m = a
if m == 1 and s == 0:
min = 0
max = 0
elif int(s) < 1 or int(s) > 9 * int(m):
min = -1
max = -1
else:
while s > 9:
min += "9"
m -= 1
s -= 9
if m != 0 and s != 0:
if m == 1:
min = str(s) + min
m -= 1
elif m > 1:
m -= 1
st = ""
st += "1"
s -= 1
st += "0" * m
st = int(st)
st = st + s
st = str(st)
min = st + min
elif m != 0 and s == 0:
min += "0" * m
max = ""
s = b
m = a
while s > 9:
max += "9"
m -= 1
s -= 9
if m != 0 and s != 0:
if m == 1:
max = max + str(s)
elif m > 1:
m -= 1
max += str(s)
max += "0" * m
elif m != 0 and s == 0:
min += "0" * m
print(min, max) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING VAR STRING VAR NUMBER VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP STRING VAR ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP STRING VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP STRING VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def get_max(sum, num, curr, length, dp):
if sum == 0 and length == 0:
return num
elif sum < 0 or length < 0:
return -1
if sum > 0 and length == 0:
return -2
ans = -1
for i in range(curr, -1, -1):
ans = get_max(sum - i, num * 10 + i, i, length - 1, dp)
if ans != -1:
return ans
elif ans == -2:
return -2
return ans
def get_min(max_num):
if max_num == "-1":
return -1
min_num = max_num[::-1]
if not (min_num[0] == "0" and len(min_num) > 1):
return min_num
lst = []
isChange = False
for num in min_num:
if num != "0" and not isChange:
min_num2 = ord(num) - ord("1")
lst.append("%d" % min_num2)
isChange = True
else:
lst.append(num)
lst[0] = "1"
return "".join(lst)
nums = input().split()
length = int(nums[0])
sum = int(nums[1])
max_num = str(get_max(sum, 0, 9, length, {}))
if len(max_num) != length or max_num == "-2":
max_num = "-1"
min_num = get_min(max_num)
print(min_num, max_num) | FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN NUMBER RETURN VAR FUNC_DEF IF VAR STRING RETURN NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER STRING RETURN FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR DICT IF FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def can(m, s):
if s >= 1 and s <= m * 9 or s == 0:
return 1
return 0
m, s = map(int, input().split())
sum = s
max = ""
min = ""
if m == 1 and s >= 0 and s <= 9:
print(s, s)
else:
for i in range(1, m + 1):
for d in range(10):
if (i == 1 and d > 0 or i > 1) and can(m - i, sum - d):
min = min + str(d)
sum = sum - d
break
else:
print("-1 -1")
break
sum = s
for i in range(1, m + 1):
for d in range(9, -1, -1):
if (i == 1 and d > 0 or i > 1) and can(m - i, sum - d):
max = max + str(d)
sum -= d
break
else:
break
else:
print(min, max) | FUNC_DEF IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n = list(map(int, input().split()))
m = int(n[0])
s = int(n[1])
del n
if s != 0 and m * 9 >= s:
snumbers = ["9"] * ((s - 1) // 9)
if m - (s - 1) // 9 == 1:
if s % 9 == 0:
snumbers.append(str("9"))
else:
snumbers.append(str(s % 9))
elif m - (s - 1) // 9 > 1:
snumbers.append(str((s - 1) % 9))
snumbers = snumbers + ["0"] * (m - (s - 1) // 9 - 2) + ["1"]
snumbers = "".join(reversed(snumbers))
lnumbers = ["9"] * (s // 9)
if m - s // 9 >= 1:
lnumbers.append(str(s % 9))
lnumbers = "".join(lnumbers) + "".join(["0"] * (m - s // 9 - 1))
else:
lnumbers = "".join(lnumbers)
print(snumbers + " " + lnumbers)
elif m == 1 and s == 0:
print("0 0")
else:
print("-1 -1") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP LIST STRING BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER LIST STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL STRING VAR FUNC_CALL STRING BIN_OP LIST STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | line = input()
m, s = [int(i) for i in line.split()]
large = 0
tiny = 0
if s == 0:
if m == 1:
print("0 0")
else:
print("-1 -1")
elif s > 9:
if s > m * 9:
print("-1 -1")
else:
t = 9
p = 9
sl = s
st = s
tiny = 9
for i in range(m):
large += t * pow(10, m - i - 1)
sl = sl - t
if sl >= 0:
if sl < t:
t = sl
for i in range(m - 1):
st = st - p
if st > 0:
if st < p:
p = st
tiny += p * pow(10, i + 1)
if tiny // pow(10, m - 1) == 0:
for i in range(m):
if tiny // pow(10, i) == 0:
tiny = tiny + pow(10, m - 1) - pow(10, i - 1)
print(tiny, large)
else:
large = s * pow(10, m - 1)
tiny = pow(10, m - 1) + s - 1
print(tiny, large) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | a, b = map(int, input().split())
h = []
l = []
if b == 0 and a > 1:
print("-1 -1")
elif b > a * 9:
print("-1 -1")
elif a == 1:
if b == 0:
print(0, 0)
elif b > 0 and b < 10:
print(b, b)
else:
print("-1 -1")
elif b == a * 9:
for i in range(a):
l.append(9)
h.append(9)
elif b == 1:
l.append(1)
h.append(1)
for i in range(a - 1):
l.append(0)
h.append(0)
elif b <= 9:
h.append(b)
for i in range(1, a):
h.append(0)
l.append(1)
for i in range(1, a - 1):
l.append(0)
l.append(b - 1)
else:
p = a - b // 9 - 1
if p == 0:
l.append(b % 9)
for i in range(a - 1):
l.append(9)
for i in range(a - 1):
h.append(9)
h.append(b % 9)
else:
l.append(1)
if b % 9 == 0:
for i in range(p):
l.append(0)
l.append(8)
for i in range(b // 9 - 1):
l.append(9)
else:
for i in range(p - 1):
l.append(0)
l.append(b % 9 - 1)
for i in range(b // 9):
l.append(9)
for i in range(b // 9):
h.append(9)
h.append(b % 9)
for i in range(p):
h.append(0)
for i in l:
print(i, end="")
print(end=" ")
for i in h:
print(i, end="") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def main():
m, s = map(int, input().split())
if s > 9 * m or s < 1 and m != 1:
print(-1, -1)
else:
print(
int(10 ** (m - 1) + ((s - 1) % 9 + 1) * 10 ** ((s - 1) // 9) - 1),
10**m - 10 ** (m - (s - 1) // 9 - 1) * (9 - (s - 1) % 9),
)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def get_min(sm, ln):
if sm == 0:
return "-1" if ln > 1 else "0"
if sm < 10 and ln == 1:
return str(sm)
elif sm < 10 and ln > 1:
return "1%s%s" % ("0" * (ln - 2), sm - 1)
else:
return "%s%s" % (get_min(sm - 9, ln - 1), 9)
def get_max(sm, ln):
if sm == 0:
return -1 if ln > 1 else "0"
if sm < 10 and ln == 1:
return str(sm)
elif sm < 10 and ln > 1:
return "%s%s" % (sm, (ln - 1) * "0")
else:
return "%s%s" % (9, get_max(sm - 9, ln - 1))
l, s = map(int, input("").split(" "))
if s > l * 9:
print("-1 -1")
else:
print(get_min(s, l), get_max(s, l)) | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER STRING STRING IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER STRING IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN BIN_OP STRING VAR BIN_OP BIN_OP VAR NUMBER STRING RETURN BIN_OP STRING NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def judge(digit, num):
if num == 0:
if digit != 1:
return -1
else:
return str(num)
elif num <= digit:
if num <= 10 and num >= 2:
return "1" + "0" * (digit - 2) + str(num - 1)
elif num == 1:
return "1" + "0" * (digit - 1)
else:
try:
return judge(digit - 1, num - 9) + "9"
except:
return -1
elif digit > 1:
if num >= 10:
try:
return judge(digit - 1, num - 9) + "9"
except:
return -1
else:
try:
return judge(digit - 1, 1) + str(num - 1)
except:
return -1
elif num <= 9:
return str(num)
else:
return -1
def chase(digit, num):
if num == 0:
if digit == 1:
return str(num)
else:
return -1
elif num <= digit:
if num <= 9:
return str(num) + "0" * (digit - 1)
else:
try:
return "9" + chase(digit - 1, num - 9)
except:
return -1
elif digit == 1:
if num >= 10:
return -1
else:
return str(num)
elif digit > 1:
if num <= 9:
return str(num) + "0" * (digit - 1)
else:
try:
return "9" + chase(digit - 1, num - 9)
except:
return -1
else:
return -1
x = input().split()
m = int(x[0])
s = int(x[1])
a = judge(m, s)
b = chase(m, s)
if a == -1:
print("-1", "-1")
elif a[-1] == "0" or len(a) == 1:
print(int(a), int(a))
else:
print(int(a), int(b)) | FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING RETURN NUMBER IF VAR NUMBER IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR VAR RETURN NUMBER FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER RETURN BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER RETURN BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING IF VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def main():
length, sum_of_digits = map(int, input().split())
min_number = max_number = -1
arr = []
if sum_of_digits == 0 and length != 1 or sum_of_digits > length * 9:
print("-1 -1")
return 0
elif length == 1:
print(sum_of_digits, sum_of_digits, sep=" ")
return 0
temp = sum_of_digits - 1
for i in range(length - 1):
arr.append(min(9, temp))
temp -= min(temp, 9)
arr.append(temp + 1)
arr = reversed(arr)
min_number = "".join(map(str, arr))
arr = []
for i in range(length):
arr.append(min(sum_of_digits, 9))
sum_of_digits -= min(sum_of_digits, 9)
max_number = "".join(map(str, arr))
print(min_number, max_number, sep=" ", end="\n")
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if 9 * m < s or m > 1 and s == 0:
print(-1, -1)
elif m == 1:
print(s, s)
else:
if s % 9 == 0:
big = "9" * (s // 9) + "0" * (m - s // 9)
if s // 9 == m:
small = "9" * m
else:
small = "1" + "0" * (m - 1 - s // 9) + "8" + "9" * (s // 9 - 1)
else:
big = "9" * (s // 9) + str(s % 9) + "0" * (m - s // 9 - 1)
small = ""
num_9 = s // 9
r = s % 9 - 1
num_0 = m - num_9 - 2
if r == -1:
small = "1" + "0" * (m - 1 - num_9) + "8" + "9" * (num_9 - 1)
elif num_0 == -1:
num_0 += 1
r += 1
small = str(r) + "9" * num_9
else:
small = "1" + "0" * num_0 + str(r) + "9" * num_9
print(small, big) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR STRING BIN_OP STRING BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | line = [int(k) for k in input().split()]
length = line[0]
dsum = line[1]
maximum = []
minimum = []
if (length == 1) & (dsum == 0):
print("0 0")
elif (dsum < 1) | (dsum > 9 * length):
print("-1 -1")
else:
a = dsum // 9
b = (dsum - 1) // 9
for i in range(a):
maximum.append("9")
if a < length:
maximum.append(str(dsum % 9))
if length - a - 1 > 0:
for i in range(length - a - 1):
maximum.append("0")
for i in range(b):
minimum.insert(0, "9")
if length == b:
minimum.insert(0, "1")
if length == b + 1:
minimum.insert(0, str((dsum - 1) % 9 + 1))
elif length == b + 2:
minimum.insert(0, str((dsum - 1) % 9))
minimum.insert(0, "1")
else:
minimum.insert(0, str((dsum - 1) % 9))
for i in range(length - b - 2):
minimum.insert(0, "0")
minimum.insert(0, "1")
print("".join(minimum), "".join(maximum)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING IF VAR VAR EXPR FUNC_CALL VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | length, sum = map(int, input().split())
if sum > 9 * length:
print("-1 -1")
elif sum == 0:
if length == 1:
print("0 0")
else:
print("-1 -1")
else:
Max = str(sum) + "0" * (length - 1)
for i in range(1, length):
if sum > 9 * i:
other = sum - 9 * i
Max = "9" * i + str(other) + "0" * (length - i - 1)
Min = "1" + "0" * (length - 2) + str(sum - 1)
for i in range(1, length):
if sum >= 1 + 9 * i:
other = sum - 9 * i - 1
if length >= 3:
Min = "1" + "0" * (length - i - 2) + str(other) + "9" * i
if length < i + 2:
other = sum - 9 * i
Min = str(other) + "9" * i
if length == 2 and sum < 9:
Min = "1" + str(sum - 1)
if length == 1:
Min = str(sum)
print(Min, Max, sep=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR 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 IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if m == 1:
if s == 0:
print("0 0")
elif s > 9:
print("-1 -1")
else:
for i in range(9, 0, -1):
if i <= s:
print(i, i)
break
elif s == 0 and m > 1:
print("-1 -1")
elif 9 * m < s:
print("-1 -1")
else:
ans = ""
stn = 0
for k in range(m - 1):
for i in range(9, -1, -1):
if i + stn < s:
ans += str(i)
stn += i
break
for i in range(9, 0, -1):
if i + stn <= s:
ans += str(i)
break
ansm = ""
stn = 0
for k in range(m):
for i in range(9, -1, -1):
if i + stn <= s:
ansm += str(i)
stn += i
break
print(ans[::-1], ansm) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def small(m, s):
if 9 * m < s or s == 0:
return -1
ans = ""
for i in range(1, m + 1):
for j in range(0, 10):
if i == 1 and j == 0:
continue
if 9 * (m - i) >= s - j:
ans += str(j)
s -= j
break
return ans
def large(m, s):
if 9 * m < s or s == 0:
return -1
ans = ""
for i in range(1, m + 1):
for j in range(9, -1, -1):
if i == 1 and j == 0:
continue
if 9 * (m - i) >= s - j and s - j >= 0:
ans += str(j)
s -= j
break
return ans
def solve(m, s):
if m == 1 and s == 0:
return [0, 0]
l = []
l.append(small(m, s))
l.append(large(m, s))
return l
m, s = map(int, input().split())
l = solve(m, s)
for i in l:
print(i, end=" ") | FUNC_DEF IF BIN_OP NUMBER VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF IF BIN_OP NUMBER VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN LIST NUMBER NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | import sys
def possible(m, s):
return s <= 9 * m and s >= 0
n = list(map(int, input().split()))
m, s = n[0], n[1]
min_remaining_sum = s
max_remaining_sum = s
if s == 0:
if m == 1:
print(0, 0)
sys.exit()
else:
print(-1, -1)
sys.exit()
if not possible(m, s):
print(-1, -1)
sys.exit()
min_ans = ""
max_ans = ""
for i in range(0, m):
for d in range(0, 10):
if (i > 0 or d > 0 or m == 1 and d == 0) and possible(
m - i - 1, min_remaining_sum - d
):
min_ans += str(d)
min_remaining_sum -= d
break
print(min_ans)
for i in range(0, m):
for d in range(9, -1, -1):
if (i > 0 or d > 0 or m == 1 and d == 0) and possible(
m - i - 1, max_remaining_sum - d
):
max_ans += str(d)
max_remaining_sum -= d
break
print(max_ans) | IMPORT FUNC_DEF RETURN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER 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 FUNC_CALL VAR VAR VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, s = map(int, input().split())
s2 = s
ans = [None] * n
if s > 9 * n:
print("-1 -1")
elif s == 0 and n != 1:
print("-1 -1")
else:
s -= 1
for i in range(n - 1, 0, -1):
if s > 9:
ans[i] = 9
s -= 9
else:
ans[i] = s
s = 0
ans[0] = s + 1
for i in ans:
print(i, end="")
print(" ", end="")
for i in range(0, n, 1):
if s2 >= 9:
ans[i] = 9
s2 -= 9
else:
ans[i] = s2
s2 = 0
for i in ans:
print(i, end="") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, s = list(map(int, input().split()))
if n != 1 and s == 0 or s > 9 * n:
print(-1, -1)
else:
a = s // 9
b = s % 9
ls = ["9"] * a + [str(b)] * bool(n - a) + ["0"] * (n - a - 1)
if a + 1 >= n:
lt = [str(b)] + ["9"] * a
elif b != 0:
lt = ["1"] + ["0"] * (n - 2 - a) + [str(b - 1)] + ["9"] * a
else:
lt = ["1"] + ["0"] * (n - a - 1) + ["8"] + ["9"] * (a - 1)
print(int("".join(lt)), int("".join(ls))) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST STRING VAR BIN_OP LIST FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP LIST STRING BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR VAR BIN_OP LIST STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP BIN_OP VAR NUMBER VAR LIST FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP BIN_OP VAR VAR NUMBER LIST STRING BIN_OP LIST STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL VAR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s == 0:
print("0 0" if m == 1 else "-1 -1")
exit()
a = "9" * (s // 9)
if s % 9 > 0:
a += f"{s % 9}"
if len(a) > m:
print("-1 -1\n")
exit()
max_ans = a
while len(a) < m:
a = a[:-1] + f"{int(a[-1]) - 1}"
while len(a) < m - 1:
a += "0"
a += "1"
min_ans = a[::-1]
while len(max_ans) < m:
max_ans += "0"
print(f"{min_ans} {max_ans}") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR STRING VAR STRING ASSIGN VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(elem) for elem in input().split()]
a = []
for i in range(101):
a.append([-1] * 901)
b = []
for i in range(101):
b.append([-1] * 901)
for j in range(10):
a[1][j] = j
b[1][j] = j
for i in range(2, 101):
for j in range(1, 10):
a[i][j] = 10 ** (i - 1) + j - 1
b[i][j] = b[i - 1][j] * 10
for j in range(10, 9 * i + 1):
a[i][j] = 9 + 10 * a[i - 1][j - 9]
b[i][j] = 9 * 10 ** (i - 1) + b[i - 1][j - 9]
print(a[m][s], b[m][s]) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(x) for x in input().split()]
if m == 1 and s >= 0 and s <= 9:
x = str(s)
y = str(s)
elif m == 1 and (s < 0 or s > 9):
x = "-1"
y = "-1"
elif m > 1 and (s < 1 or s > 9 * m):
x = "-1"
y = "-1"
else:
a = s - 1
b = 9 * m - s
c = a // 9
d = a % 9
e = b // 9
f = b % 9
if c < m - 1:
x = "1" + "0" * (m - c - 2) + str(d) + "9" * c
else:
x = str(1 + d) + "9" * (m - 1)
y = "9" * (m - e - 1) + str(9 - f) + "0" * e
print(int("".join(x)), int("".join(y))) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP 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 STRING BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL VAR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = [int(i) for i in input().split()]
if s == 0 and m != 1 or s > 9 * m:
print(-1, -1)
else:
a = 10 ** ((s - 1) // 9) * ((s - 1) % 9 + 1) - 1 + 10 ** (m - 1)
b = 10**m - 10 ** (m - (s - 1) // 9 - 1) * (10 - (s - (s - 1) // 9 * 9))
print(int(a), b) | 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def can(n, s):
return s >= 0 and s <= 9 * n
n, s = [int(x) for x in input().split()]
if n == 1 and s == 0:
print("0 0")
else:
small = ""
sum = s
for i in range(1, n + 1):
for d in range(0, 10):
if i == 1 and d == 0:
continue
if can(n - i, s - d):
small += str(d)
s -= d
break
large = ""
s = sum
for i in range(1, n + 1):
for d in range(9, -1, -1):
if i == 1 and d == 0:
continue
if can(n - i, s - d):
large += str(d)
s -= d
break
if small == "" or small[0] == "0":
print("-1 -1")
else:
print(small, large) | FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR 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 NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def min_n(m, s, n):
n += pow(10, m - 1)
s -= 1
i = 0
while s > 0:
if s > 9:
n += 9 * pow(10, i)
s -= 9
i += 1
else:
n += s * pow(10, i)
s -= s * pow(10, i)
i += 1
return n
def max_n(m, s, n):
i = m - 1
while s > 0:
if s > 9:
n += 9 * pow(10, i)
s -= 9
i -= 1
else:
n += s * pow(10, i)
s = 0
i -= 1
return n
n = 0
m, s = input().split()
m = int(m)
s = int(s)
if m == 1 and s == 0:
print("0 0")
elif s == 0 or s > 9 * m:
print("-1 -1")
else:
n1 = n
print(min_n(m, s, n), max_n(m, s, n1)) | FUNC_DEF VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | st = input().split()
a = int(st[0])
b = int(st[1])
if b == 0:
if a == 1:
print("0 0")
else:
print("-1 -1")
elif 9 * a < b:
print("-1 -1")
else:
mini = int(10 ** (a - 1))
aux = b
b -= 1
i = 0
while b > 9:
mini += 9 * 10**i
i += 1
b -= 9
mini += b * 10**i
b = aux
i = a - 1
maxi = 0
while b > 9:
maxi += 9 * 10**i
i -= 1
b -= 9
maxi += b * 10**i
print(str(mini) + " " + str(maxi)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
def sum_digits(n):
s = 0
while n:
s += n % 10
n //= 10
return s
s2 = s
s3 = s
low = ""
high = ""
if s == 0 and m != 1 or s > m * 9:
print("-1 -1")
else:
for digit in range(m):
if digit == m - 1:
low = str(s2) + low
elif s2 > 9:
low = "9" + low
s2 -= 9
else:
low = str(s2 - 1) + low
s2 -= s2 - 1
for digit in range(m):
if s3 >= 9:
high = high + "9"
s3 -= 9
else:
high = high + str(s3)
s3 -= s3
print(low + " " + high) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | L = 105
maxi = [0] * L
for x in range(1, L):
maxi[x] = maxi[x - 1] + 9
def ok(su, dl):
return su >= 0 and su <= maxi[dl]
def maly(su, dl, p):
if dl == 1:
return su
for cyf in range(p, 10):
if ok(su - cyf, dl - 1):
return cyf * 10 ** (dl - 1) + maly(su - cyf, dl - 1, 0)
def duzy(su, dl, p):
if dl == 1:
return su
for cyf in range(9, p - 1, -1):
if ok(su - cyf, dl - 1):
return cyf * 10 ** (dl - 1) + duzy(su - cyf, dl - 1, 0)
In = input().split()
m = int(In[0])
s = int(In[1])
if m > 1 and s < 1 or s > maxi[m]:
print("-1 -1")
else:
print(maly(s, m, 1), duzy(s, m, 1)) | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN VAR NUMBER VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER 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 VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | def solve(var_length, var_sum):
smallest = ""
largest = ""
small_sum = var_sum - 1
for i in range(var_length - 1):
if small_sum > 9:
smallest += "9"
small_sum -= 9
else:
smallest += str(small_sum)
small_sum = 0
smallest += str(small_sum + 1)
for j in range(var_length):
if var_sum > 9:
largest += "9"
var_sum -= 9
else:
largest += str(var_sum)
var_sum = 0
return [smallest[::-1], largest]
[length, sum_digit] = [int(x) for x in input().split()]
if 0 < sum_digit <= length * 9:
answer = solve(length, sum_digit)
print(answer[0], answer[1])
elif length == 1 and sum_digit == 0:
print(0, 0)
else:
print(-1, -1) | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER RETURN LIST VAR NUMBER VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | length, summ = [int(x) for x in input().split()]
if summ == 0 and length == 1:
print(0, 0)
elif summ > length * 9 or summ == 0:
print(-1, -1)
else:
maxx = [0] * length
temp_sum = summ
i = 0
while temp_sum > 0:
if temp_sum <= 9:
maxx[i] = temp_sum
break
else:
maxx[i] = 9
i += 1
temp_sum -= 9
minn = list(maxx)
minn.reverse()
if minn[0] == 0:
for i in range(len(minn)):
if minn[i] != 0:
minn[i] -= 1
minn[0] = 1
break
for i in minn:
print(i, end="")
print(end=" ")
for i in maxx:
print(i, end="") | 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 BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | line = input()
m, s = line.split()
m = int(m)
s = int(s)
ss = s - 1
a = []
b = []
big = ""
small = ""
if m == 1 and s == 0:
print("0 0")
elif s > 9 * m or s == 0 and m != 1:
print("-1 -1")
else:
for i in range(m):
n = min(s, 9)
if n >= 0:
a.append(n)
else:
a.append(0)
s = s - n
for i in range(m, 0, -1):
n = min(ss, 9)
if n > 0:
b.append(n)
else:
b.append(0)
ss = ss - n
if b[m - 1] > 0:
b[m - 1] = b[m - 1] + 1
else:
b[m - 1] = 1
for i in range(m - 1, -1, -1):
big = big + str(b[i])
for i in range(m):
small = small + str(a[i])
big = int(big)
small = int(small)
print(big, small) | 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 VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s == 0 or s > 9 * m:
if s == 0 and m == 1:
print("0 0")
else:
print("-1 -1")
else:
sg = sd = s
cmin = cmax = ""
for i in range(m):
c = 1 if i == 0 else 0
g = max(c, sg - 9 * (m - i - 1))
sg -= g
d = min(9, sd)
sd -= d
cmin += str(g)
cmax += str(d)
print(cmin, cmax) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | n, s = map(int, input().split())
a = []
flag = 0
chck = 0
for i in range(n):
chck += 9
if s == 0:
if n == 1:
print(0, 0)
flag = 1
else:
flag = 1
print(-1, -1)
if chck < s and flag == 0:
print(-1, -1)
flag = 1
for i in range(n):
if len(str(s)) > 1:
z = 9
else:
z = min(9, s)
a.append(z)
s = s - z
a1 = ""
b1 = ""
for i in range(n):
a1 += str(a[i])
b1 = ""
b = a[::-1]
if b[0] == 0:
b[0] = 1
for i in range(1, n):
if b[i] > 0:
b[i] -= 1
break
for i in range(n):
b1 += str(b[i])
if flag == 0:
print(b1, a1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s > int(9 * m):
res = "-1 -1"
elif s == 0:
if m == 1:
res = "0 0"
else:
res = "-1 -1"
else:
small = [0] * m
s_temp = s
for i in range(m - 1, -1, -1):
x = min(9, s)
if x == 0:
j = i + 1
while not small[j]:
j += 1
small[j] -= 1
s += 1
x = 1
small[i] = x
s -= x
small = list(map(str, small))
small = "".join(small)
big = [0] * m
i = 0
s = s_temp
while s:
x = min(9, s)
big[i] = x
s -= x
i += 1
big = list(map(str, big))
big = "".join(big)
res = " ".join([small, big])
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING LIST VAR VAR EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if m * 9 < s or s == 0 and m > 1:
print("-1 -1")
else:
s2 = s - 1
m2 = m
res1 = ""
res2 = ""
while m:
res1 += str(min(9, s))
s = max(0, s - 9)
if m == 1:
s2 += 1
res2 = str(min(9, s2)) + res2
s2 = max(0, s2 - 9)
m -= 1
print(res2, res1) | 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 VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
if s == 0:
if m == 1:
print("0 0")
else:
print("-1 -1")
elif m * 9 < s:
print("-1 -1")
else:
a = [(0) for i in range(m)]
a[m - 1] = 1
cnt = s - 1
for i in range(m):
while cnt > 0 and a[i] < 9:
a[i] += 1
cnt -= 1
print("".join(map(str, reversed(a))), end=" ")
a = [(0) for i in range(m)]
a[0] = 1
cnt = s - 1
for i in range(m):
while cnt > 0 and a[i] < 9:
a[i] += 1
cnt -= 1
print("".join(map(str, a))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains a pair of integers m, s (1 β€ m β€ 100, 0 β€ s β€ 900) β the length and the sum of the digits of the required numbers.
-----Output-----
In the output print the pair of the required non-negative integer numbers β first the minimum possible number, then β the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).
-----Examples-----
Input
2 15
Output
69 96
Input
3 0
Output
-1 -1 | m, s = map(int, input().split())
y = m
t = ""
if m == 0:
print(-1, -1)
elif s == 0 and m > 1:
print(-1, -1)
elif s > m * 9:
print(-1, -1)
else:
t = ""
while m:
if s - 9 > 0:
t += "9"
s -= 9
m -= 1
elif s - 9 == 0:
t += "9"
m -= 1
break
else:
t += str(s)
m -= 1
break
if len(t) == y:
mi = t[::-1]
MA = t
else:
MA = t + "0" * (y - len(t))
mi = "1"
y = 0
for k in range(1, len(MA)):
if y == 0 and MA[::-1][k] != "0":
mi += str(int(MA[::-1][k]) - 1)
y += 1
else:
mi += MA[::-1][k]
print(mi, MA) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING WHILE VAR IF BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR STRING VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.