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 | d, sum = map(int, input().split())
pus = sum
mxs = ""
for i in range(d):
for j in range(9, -1, -1):
if i == d - 1:
if 0 <= sum <= 9:
mxs += str(sum)
break
elif 0 <= (sum - j) / (d - i - 1) <= 9:
mxs += str(j)
sum -= j
break
mns = ""
sum = pus
for i in range(d):
if i == d - 1:
if 0 <= sum <= 9:
mns += str(sum)
elif i == 0:
for j in range(1, 10):
if 0 <= (sum - j) / (d - i - 1) <= 9:
mns += str(j)
sum -= j
break
else:
for j in range(10):
if 0 <= (sum - j) / (d - i - 1) <= 9:
mns += str(j)
sum -= j
break
if mxs.count("0") == d and d > 1:
mxs = "-1"
if mns.count("0") == d and d > 1:
mns = "-1"
print(mns if len(mns) == d else -1, mxs if len(mxs) == d else -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR IF NUMBER BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF NUMBER BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF NUMBER BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR STRING VAR VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR STRING VAR VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_CALL VAR 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 | [m, s] = [int(x) for x in input().split(" ")]
if m == 1 and s == 0:
print(0, 0)
elif 9 * m < s or s < 1:
print("-1 -1")
else:
smallest = [1] + [0] * (m - 1)
largest = [9] * m
d = s - sum(smallest)
i = -1
while d > 9:
d -= 9
smallest[i] = 9
i -= 1
if d > 0:
smallest[i] += d
d = sum(largest) - s
i = -1
while d > 9:
d -= 9
largest[i] = 0
i -= 1
if d > 0:
largest[i] -= d
print("".join([str(x) for x in smallest]), "".join([str(x) for x in largest])) | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR 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 | n, m = list(map(int, input().split()))
c = n
if n == 1 and m == 0:
print("0 0")
elif 9 * n < m or m < 1:
print("-1 -1")
else:
a = m // 9
b = str(m % 9)
number = []
if n >= 2:
for i in range(1, 10):
if (m - i) / (n - 1) <= 9:
break
n -= 1
m -= i
number.append(i)
while n > 1:
for i in range(10):
if (m - i) / (n - 1) <= 9:
break
number.append(i)
n -= 1
m -= i
number.append(m)
v = list(map(str, number))
if b == "0":
print("".join(v), "9" * a + "0" * (c - a))
else:
print("".join(v), "9" * a + b + "0" * (c - a - 1)) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR VAR BIN_OP STRING BIN_OP BIN_OP 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 | k = input().split()
n = int(k[0])
s = int(k[1])
result = []
len = n
sum = s
small_num = 0
small_num_index = 0
if sum > 9 * n or sum == 0 and n > 1:
print("-1 -1")
else:
for i in range(n):
if sum == 0:
result.append(0)
len -= 1
elif sum - 9 > 0:
sum -= 9
result.append(9)
len -= 1
else:
result.append(sum)
small_num = sum
small_num_index = i
sum = 0
len -= 1
sum = s
len = n
if sum == 0:
print("0", end="")
len -= 1
elif sum - 1 <= 9 * (len - 1):
print("1", end="")
len -= 1
sum -= 1
else:
print(sum - 9 * (len - 1), end="")
len -= 1
sum = 9 * len
for i in range(n - 1):
if sum <= 9 * (len - 1):
print("0", end="")
len -= 1
else:
print(sum - 9 * (len - 1), end="")
len -= 1
sum = 9 * len
print(" ", end="")
for i in range(n):
print(result[i], end="")
print() | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR 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 s == 0 and m == 1:
print(0, 0)
elif s == 0:
print(-1, -1)
elif m * 9 < s:
print(-1, -1)
else:
nums = []
while len(nums) < m:
nums.append(min(9, s))
s = s - min(9, s)
max_nums = [str(i) for i in nums]
max_num = "".join(max_nums)
min_nums = nums[::-1]
if min_nums[0] == 0:
for j, num in enumerate(min_nums):
if num != 0:
min_nums[j] = num - 1
break
min_nums[0] = 1
min_nums = [str(i) for i in min_nums]
min_num = "".join(min_nums)
print(min_num, max_num) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL 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 | import sys
m, s = [int(i) for i in input().split()]
if s < 1:
if m == 1:
print("0 0")
sys.exit(0)
else:
print("-1 -1")
sys.exit(0)
l1 = ""
s1 = s
for i in range(m):
if s1 == 0:
l1 += str(s1)
elif s1 < 9:
l1 += str(s1)
s1 = 0
else:
l1 += str(9)
s1 -= 9
if s1 > 0:
print("-1 -1")
sys.exit(0)
l2 = ""
s2 = s - 1
for i in range(m - 1):
if s2 == 0:
l2 += str(s2)
elif s2 < 9:
l2 += str(s2)
s2 = 0
else:
l2 += str(9)
s2 -= 9
if s2 == 0:
l2 += "1"
else:
l2 += str(1 + s2)
l2 = l2[::-1]
print(l2, l1) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER VAR STRING VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN 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 | def digit(m, s):
return s >= 0 and s <= 9 * m
try:
lowest = ""
highest = ""
a = input().split()
m = int(a[0])
s = int(a[1])
total = s
if not digit(m, s) or s == 0:
if m == 1 and s == 0:
print("0 0")
else:
print("-1 -1")
x = 1 / 0
for i in range(m):
for j in range(10):
if (i > 0 or j > 0 or m == 1 and j == 0) and digit(m - i - 1, total - j):
lowest += str(j)
total -= j
break
total = s
for i in range(m):
for j in range(9, 0, -1):
if digit(m - i - 1, total - j):
highest += str(j)
total -= j
break
while True:
if len(highest) < m:
highest += "0"
else:
break
print(lowest, highest)
except:
a = 1 + 1 | FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR 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 ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR WHILE NUMBER IF FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP 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 | d, s = map(int, input().split())
small = [0] * d
large = [0] * d
small[0] = 1
smallCurrSum = 1
large[0] = min(9, s)
largeCurrSum = large[0]
smallLeft = s - smallCurrSum
largeLeft = s - largeCurrSum
for x in range(d - 1, 0, -1):
small[x] = min(9, smallLeft)
smallLeft -= small[x]
for x in range(1, d):
large[x] = min(9, largeLeft)
largeLeft -= large[x]
if smallLeft > 0:
small[0] = min(8, smallLeft) + 1
smallLeft -= small[0]
if s == 0:
small[0] = 0
if s == 0 and d > 1 or smallLeft > 0 or largeLeft > 0:
print(-1, -1)
else:
print("".join(list(map(str, small))), "".join(list(map(str, large)))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL STRING 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 | from sys import stdin, stdout
def main():
length, total = [int(i) for i in stdin.readline().split()]
if length == 1 and total == 0:
stdout.write("0 0\n")
elif total == 0 or total > 9 * length:
stdout.write("-1 -1\n")
else:
arr = []
for i in range(length):
arr = arr + [10**i] * 9
upper = 0
for i in range(total):
upper += arr.pop(-1)
if len(arr) == 0:
break
arr = []
for i in range(length):
arr = arr + [10**i] * 9
lower = 0
lower += arr.pop(-1)
for i in range(total - 1):
lower += arr.pop(0)
if len(arr) == 0:
break
stdout.write(str(lower) + " " + str(upper) + "\n")
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP LIST BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP LIST BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR 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 | n, s = input().split(" ")
n = int(n)
s = int(s)
x = [i for i in range(10)]
x.reverse()
maxi = 0
mini = 0
sum = 0
flag = 0
for i in range(n):
for j in x:
if i == 0 and j == 0:
flag = -1
break
if j <= s - sum and (n - i - 1) * 9 >= s - sum - j:
maxi += 10 ** (n - i - 1) * j
sum += j
break
elif j == 0:
flag = -1
if flag == -1:
break
if flag == -1:
maxi = -1
flag = 0
sum = 0
x.reverse()
for i in range(n):
for j in x:
if i == 0 and j == 0:
continue
if j <= s - sum and (n - i - 1) * 9 >= s - sum - j:
mini += 10 ** (n - i - 1) * j
sum += j
break
elif j == 9:
flag = -1
if flag == -1 or mini == 0:
mini = -1
if n == 1 and s == 0:
print(0, 0)
else:
print(mini, maxi) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL 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 | tamanho, aux = map(int, input().split())
maiorSoma = aux
maiorNumero = ""
while len(maiorNumero) < tamanho:
if maiorSoma > 9:
maiorSoma -= 9
maiorNumero += "9"
elif maiorSoma != 0:
maiorNumero += str(maiorSoma)
maiorSoma = 0
else:
maiorNumero += "0"
if maiorNumero[-1] == "0":
menorNumero = list(maiorNumero[::-1])
for i in range(len(menorNumero)):
if menorNumero[i] != "0":
menorNumero[i] = str(int(menorNumero[i]) - 1)
menorNumero[0] = "1"
break
else:
menorNumero = list(maiorNumero[::-1])
if (aux != 0 or aux == 0 and tamanho == 1) and maiorSoma == 0:
print("%s %s" % ("".join(menorNumero), maiorNumero))
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR STRING IF VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL STRING VAR 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 | m, s = map(int, input().split())
ch = ""
ch1 = ""
x = s
if m * 9 < s or s == 0 and m != 1:
print("-1 -1")
elif s == 0 and m == 1:
print("0 0")
else:
for i in range(m):
ch += str(min(x, 9))
x -= min(x, 9)
ch1 = ch[::-1]
if ch1.count("0") == 0:
print(ch1, " ", ch, sep="")
else:
ch2 = list(ch1)
ch2[ch1.count("0")], ch2[0] = ch2[0], ch2[ch1.count("0")]
ch2[ch1.count("0")] = str(max(int(ch2[0]) - 1, 0))
ch2[0] = "1"
print("".join(ch2), " ", ch) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input 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()))
smin = s
lstmax = [(0) for i in range(m)]
lstmin = [(0) for i in range(m)]
for i in range(m):
if s == 0:
lstmax[i] = 0
elif s >= 9:
lstmax[i] = 9
s -= 9
else:
lstmax[i] = s
s = 0
if m == 1 and smin == 0:
print(0, 0)
elif s == 0 and smin != 0:
lstmin = lstmax[::-1]
if lstmin[0] == 0:
lstmin[0] = 1
j = 1
while lstmin[j] == 0:
j += 1
lstmin[j] -= 1
for i in range(len(lstmin)):
print(lstmin[i], end="")
print(" ", end="")
for i in range(len(lstmax)):
print(lstmax[i], end="")
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL 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 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 = [int(x) for x in input().split()]
sup = [9] * m
inf = [1] + [0] * (m - 1)
diff_lower = s - 1
diff_upper = 9 * m - s
if 9 * m >= s and s != 0:
for i in range(m - 1, -1, -1):
if diff_upper // 9 > 0:
sup[i] = 0
diff_upper = diff_upper - 9
else:
sup[i] = sup[i] - diff_upper % 9
break
for i in range(m - 1, -1, -1):
if diff_lower // 9 > 0:
inf[i] = 9
diff_lower = diff_lower - 9
else:
inf[i] = inf[i] + diff_lower % 9
break
print(*inf, sep="", end=" ")
print(*sup, sep="")
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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR VAR STRING 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 | m, s = [int(x) for x in input().split()]
if m == 1 and s == 0:
print(0, 0)
elif s > 9 * m or s == 0 and m != 0:
print(-1, -1)
else:
a = ""
wei = s // 9
for i in range(wei):
a = a + "9"
if s % 9 != 0:
a = a + str(s % 9)
if len(a) < m:
a = a + "0" * (m - len(a))
elif len(a) > m:
a = a[: len(a) - m]
b = a[::-1]
if b[0] == "0":
b = "1" + b[1:]
count = 0
for i in range(1, len(a)):
if count == 0:
if b[i] != "0":
count += 1
b = b[0:i] + str(int(b[i]) - 1) + b[i + 1 :]
print(b, a) | 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 NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR BIN_OP STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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 | m, s = map(int, input().split())
if m == 1 and s < 10:
print(s, s)
elif s == 0 or s > 9 * m:
print(-1, -1)
else:
a = (s - 1) // 9
b = (s - 1) % 9
c = sum(9 * 10**i for i in range(a)) + 10 ** (m - 1) + b * 10 ** min(a, m - 1)
d = sum(9 * 10**i for i in range(m - s // 9, m)) + s % 9 * 10 ** max(
m - s // 9 - 1, 0
)
print(c, d) | 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 NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER 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 | def F1(m, z):
s1 = ""
m1 = 0
z1 = 0
o = 0
while True:
if o == 1:
break
if m1 == m:
if z1 < z:
return "-1"
break
else:
s1 = s1[::-1]
return s1
break
elif z1 + 9 < z:
z1 += 9
s1 += "9"
m1 += 1
else:
m1 += 1
if m1 == m:
s1 += str(z - z1)
z1 = z
s1 = s1[::-1]
return s1
break
else:
s1 += str(z - z1 - 1)
z1 = z - 1
while m1 < m - 1:
m1 += 1
s1 += "0"
s1 += "1"
s1 = s1[::-1]
return s1
break
def F2(m, z):
s1 = ""
m1 = 0
z1 = 0
o = 0
while True:
if o == 1:
break
if m1 == m:
if z1 < z:
return "-1"
break
else:
return s1
break
elif z1 + 9 < z:
z1 += 9
s1 += "9"
m1 += 1
else:
m1 += 1
if m1 == m:
s1 += str(z - z1)
z1 = z
return s1
break
else:
s1 += str(z - z1)
z1 = z
while m1 < m:
m1 += 1
s1 += "0"
return s1
break
s1 = ""
s2 = ""
m, s = map(int, input().split())
if m == 1 and s == 0:
print(0, 0)
elif m != 1 and s == 0:
print(-1, -1)
else:
print(F1(m, s), F2(m, s)) | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER IF VAR VAR IF VAR VAR RETURN STRING ASSIGN VAR VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER VAR STRING VAR STRING ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER IF VAR VAR IF VAR VAR RETURN STRING RETURN VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR STRING RETURN VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER 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 | a, b = list(map(int, input().split()))
if a == 1 and b == 0:
print("0 0")
return
if b == 0 or b > a * 9:
print("-1 -1")
return
ob = b
ans = ""
for x in range(a):
if ob > 9:
ob -= 9
ans += "9"
else:
ans += str(ob)
ob = 0
big = ans
ans = ""
ob = b
ob -= 1
for x in range(a):
if ob > 9:
ob -= 9
ans = "9" + ans
else:
ans = str(ob) + ans
ob = 0
ans = chr(ord(ans[0]) + 1) + ans[1:]
print(ans, big) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 | def maxNumber(m, sumLeft):
if sumLeft <= 0:
return -1
maxNumber = [(0) for _ in range(m)]
index = 0
while sumLeft >= 9 and index < len(maxNumber):
maxNumber[index] += 9
sumLeft -= 9
index += 1
if sumLeft > 0 and index >= len(maxNumber):
return -1
elif sumLeft < 0:
return -1
elif sumLeft > 0:
maxNumber[index] += sumLeft
return int("".join(str(i) for i in maxNumber))
def minNumber(m, sumLeft):
minNumber = [(0) for _ in range(m)]
minNumber[0] = 1
sumLeft -= 1
if sumLeft < 0:
return -1
index = m - 1
while sumLeft >= 9 and index > 0:
minNumber[index] += 9
sumLeft -= 9
index -= 1
if index == 0 and sumLeft <= 8:
minNumber[0] += sumLeft
sumLeft = 0
elif index == 0 and sumLeft >= 9:
return -1
elif index != 0 and sumLeft <= 9:
minNumber[index] += sumLeft
sumLeft = 0
if sumLeft != 0:
return -1
return int("".join(str(i) for i in minNumber))
m, s = list(map(int, input().split(" ")))
if m == 1 and s == 0:
print("0 0")
else:
maxNum = maxNumber(m, s)
minNum = minNumber(m, s)
if maxNum == -1 or minNum == -1:
print("-1 -1")
else:
print(str(minNum) + " " + str(maxNum)) | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR VAR VAR RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 | a = input().split()
m = int(a[0])
n = int(a[1])
p = m
u = m
t = n
if n == 0 and m != 1 or n > 9 * m:
print("-1 -1")
elif n == 0 and m == 1:
print("0 0")
else:
l = []
while m > 0 and n > 9:
l.append(9)
n = n - 9
m = m - 1
l.append(n)
if m > 1:
for i in range(0, m - 1):
l.append(0)
y = 0
for i in range(0, p):
y += l[i] * 10 ** (p - 1 - i)
lit = []
while u > 0 and t > 9:
lit.append(9)
u = u - 1
t = t - 9
if u == 1:
lit.append(t)
elif u > 2:
lit.append(t - 1)
for i in range(0, u - 2):
lit.append(0)
lit.append(1)
else:
lit.append(t - 1)
lit.append(1)
x = 0
for i in range(0, p):
x += lit[i] * 10**i
print(x, end=" ")
print(y) | 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 VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR BIN_OP NUMBER 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 | L = [int(x) for x in input().split()]
if L[1] > L[0] * 9 or L[1] == 0 and L[0] != 1:
max = -1
else:
a = L[1]
b = L[0] - 1
c = 0
i = 0
while b >= 0:
if a >= 9:
c += 9 * 10**b
a -= 9
b -= 1
else:
c += a * 10**b
a = 0
b -= 1
max = c
if L[1] > L[0] * 9 or L[1] == 0 and L[0] != 1:
m = -1
elif L[1] == 0 and L[0] == 1:
m = 0
elif L[1] > (L[0] - 1) * 9:
m = str(L[1] - (L[0] - 1) * 9) + "9" * (L[0] - 1)
else:
f = (L[1] - 1) // 9
g = (L[1] - 1) % 9
h = str(g) + "9" * f
m = "1" + "0" * (L[0] - (1 + len(h))) + h
print(str(m) + " " + str(max)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR 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 | def maxLimitNo(m, s):
if m * 9 < s:
return "-1"
if m > 1 and s == 0:
return "-1"
i = 0
ans = ""
flag = True
while i < m:
if not flag:
i += 1
ans += "0"
continue
num = s - 9
if num >= 0:
ans += "9"
s -= 9
elif num < 0:
ans += str(s)
flag = False
i += 1
return ans
def minNumber(m, s):
if m * 9 < s or m > 1 and s < 1:
return "-1"
if m == 1 and s == 0:
return "0"
i = 0
ans = "1"
flag = True
n = s - (m - 1) * 9
if n > 0:
s -= n
m -= 1
ans = str(n)
else:
s -= 1
m -= 1
ans2 = maxLimitNo(m, s)
if ans2 == "-1":
if m <= 0:
return ans
ans2 = ""
while i < m:
ans2 += "0"
i += 1
return ans + ans2[::-1]
m, s = map(int, input().split(" "))
print(minNumber(m, s), maxLimitNo(m, s), sep=" ") | FUNC_DEF IF BIN_OP VAR NUMBER VAR RETURN STRING IF VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING IF VAR NUMBER RETURN VAR ASSIGN VAR STRING WHILE VAR VAR VAR STRING VAR NUMBER RETURN BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR 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 check(m, s):
return 0 <= s <= 9 * m
def solve():
m, s = map(int, input().split())
ans_min, ans_max, remaining = [], [], s
for i in range(m):
for j in range(10):
if (i > 0 or j > 0 or m == 1 and j == 0) and check(
m - i - 1, remaining - j
):
ans_min.append(j)
remaining -= j
break
remaining = s
for i in range(m):
for j in range(9, -1, -1):
if (i > 0 or j > 0 or m == 1 and j == 0) and check(
m - i - 1, remaining - j
):
ans_max.append(j)
remaining -= j
break
if sum(ans_min) == s and len(ans_min) == m:
print("".join(str(d) for d in ans_min), end=" ")
print("".join(str(d) for d in ans_max))
else:
print("-1 -1")
solve() | FUNC_DEF RETURN NUMBER VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST LIST VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR 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 | def can(m, s):
return s >= 0 and s <= 9 * m
s = input().split(" ")
l = int(s[0])
s = int(s[1])
a1 = ""
a2 = ""
s1 = s
s2 = s
if s != 0 and l * 9 >= s or s == 0 and l == 1:
for i in range(l):
if s1 >= 9:
a1 += "9"
s1 -= 9
else:
a1 += chr(s1 + ord("0"))
s1 = 0
for i in range(l):
for d in range(10):
if (i > 0 or d > 0 or l == 1 and d == 0) and can(l - i - 1, s2 - d):
a2 += chr(ord("0") + d)
s2 -= d
break
print(a2, a1)
else:
print(-1, -1) | FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR 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 BIN_OP FUNC_CALL VAR STRING VAR VAR VAR 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 | x, y = map(int, input().split())
listMax = []
m = 0
strMax = ""
if x == 1:
if y > 9:
print("-1", "-1")
else:
print(y, y)
else:
for i in range(0, x):
if y >= 9:
listMax.append(9)
y -= 9
strMax += "9"
m += 1
elif 0 < y < 9:
listMax.append(y)
strMax += str(y)
y = 0
else:
listMax.append(0)
strMax += "0"
if y > 0:
strMax = "0"
if int(strMax) == 0:
print("-1", "-1")
elif m == x:
listMin = listMax[::-1]
strMin = ""
for i in listMin:
strMin += str(i)
print(strMin, strMax)
else:
lastNum = listMax[m]
a = listMax[-1]
if lastNum >= 1 and a == 0:
listMax[m] = lastNum - 1
listMax[-1] = 1
elif lastNum == 0 and a == 0:
listMax[m - 1] = 8
listMax[-1] = 1
listMin = listMax[::-1]
strMin = ""
for x in listMin:
strMin += str(x)
print(strMin, strMax) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER VAR STRING VAR NUMBER IF NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR STRING IF VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING STRING IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR 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 | m, s = map(int, input().split())
if s == 0 and m > 1 or s > m * 9:
print(-1, -1)
else:
big = ["0" for _ in range(m)]
small = ["0" for _ in range(m)]
s1 = s2 = s
for i in range(m):
if s1 > 9:
big[i] = "9"
s1 -= 9
else:
big[i] = str(s1)
break
if s2 == 0:
small[0] = "0"
elif s2 > (m - 1) * 9 + 1:
small[0] = str(s2 - (m - 1) * 9)
for i in range(1, m):
small[i] = "9"
else:
small[0] = "1"
s2 -= 1
for i in reversed(range(1, m)):
if s2 > 9:
small[i] = "9"
s2 -= 9
else:
small[i] = str(s2)
break
print(int("".join(small)), int("".join(big))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER STRING IF VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR STRING ASSIGN VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR 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 | import sys
inf = float("inf")
mod, MOD = 1000000007, 998244353
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
digits, s = get_ints()
if s > digits * 9:
print(-1, -1)
exit()
if s == 0:
if digits == 1:
print(0, 0)
else:
print(-1, -1)
exit()
score = s
mini = [0] * digits
maxi = [0] * digits
for i in range(digits):
maxi[i] = t = str(min(s, 9))
s -= int(t)
score -= 1
mini[0] = 1
for i in range(digits):
mini[~i] = t = str(min(score, 9) + mini[~i])
score -= int(t)
print("".join(mini), "".join(maxi)) | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR 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 | m, s = map(int, input().split())
if s == 0 and m > 1:
s = -1
ans = ""
ans1 = ""
s1 = s - 1
k = 0
while s > 0:
if s >= 9:
ans += "9"
s -= 9
else:
ans += str(s)
s -= s
t = 0
if len(ans) > 0:
t = 1 if len(ans) < m else 0
ans1 = str(int(ans) - t)
k += t
if len(ans) > m or len(ans1) > m or s == -1:
print("-1 -1")
elif s1 == -1 and m == 1:
print("0 0")
else:
ans = ans + (m - len(ans)) * "0"
ans1 = "1" * k + "0" * (m - len(ans1) - 1) + ans1[::-1]
print(ans1, ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING BIN_OP BIN_OP VAR 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 | a = list(map(int, input().split()))
m = a[0]
s = a[1]
mx = []
mi = []
for i in range(1, 1 + m):
v = s - (m - i) * 9
if v > 0:
mx.append(v)
s -= v
elif i == 1:
mx.append(1)
s -= 1
else:
mx.append(0)
s = a[1]
for i in range(1, 1 + m):
u = s
if u < 9:
mi.append(u)
s -= u
else:
mi.append(9)
s -= 9
if a[1] == 0 and m != 1 or a[1] > 9 * m:
print("-1 -1")
elif a[1] == 0 and m == 1:
print("0 0")
else:
mini = "".join(str(i) for i in mx)
mac = "".join(str(i) for i in mi)
print(mini, mac) | 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 NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 | x, y = input().split()
x = int(x)
y = int(y)
k = 1
if y > x * 9:
print("-1 -1")
elif x == 1 and y < 10 and y != 0:
print("%d %d" % (y, y))
elif y == 0 and x != 1:
print("-1 -1")
elif y == 0 and x == 1:
print("0 0")
else:
s = y // 9
t = y % 9
if t != 0 and s != 0:
Max = "9"
for i in range(s - 1):
Max = Max + "9"
Max = Max + "%d" % t
for i in range(x - s - 1):
Max = Max + "0"
if 1 + s == x:
Min = str(t)
for i in range(x - 1):
Min = Min + "9"
if 1 + s < x:
Min = "1"
for i in range(x - 2 - s):
Min = Min + "0"
Min = Min + "%d" % (t - 1)
for i in range(s):
Min = Min + "9"
print(Min, Max)
while k == 1:
break
if t == 0:
Max = "9"
for i in range(s - 1):
Max = Max + "9"
for i in range(x - s):
Max = Max + "0"
if s != x:
Min = "1"
for i in range(x - s - 1):
Min = Min + "0"
Min = Min + "8"
for i in range(s - 1):
Min = Min + "9"
if s == x:
Min = Max
print(Min, Max)
while k == 1:
break
elif s == 0:
Max = str(t)
for i in range(x - 1):
Max = Max + "0"
Min = "1"
for i in range(x - 2):
Min = Min + "0"
Min = Min + "%d" % (t - 1)
print(Min, Max) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF BIN_OP NUMBER VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR STRING IF VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP STRING 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 | m, s = map(int, input().split())
lmin = [0] * (m - 1)
lmin.insert(0, 1)
sum1 = sum(lmin)
lmax = [9] * m
sum2 = sum(lmax)
x = ""
y = ""
flag = 1
if m == 0:
print(-1, -1)
elif m == 1 and (s >= 0 and s <= 9):
print(s, s)
elif m > 1 and (s >= 1 and s <= m * 9):
if sum1 == s:
for i in lmin:
x = x + str(i)
else:
j = m - 1
while j >= 0:
if sum1 + 9 >= s:
if j == 0:
a = s - sum1 + 1
sum1 = sum1 + a - 1
else:
a = s - sum1
sum1 = sum1 + a
lmin[j] = a
break
else:
sum1 = sum1 + 9
lmin[j] = 9
j = j - 1
if sum(lmin) == s:
for i in lmin:
x = x + str(i)
else:
flag = 0
print(-1, -1)
if flag == 1:
if sum2 == s:
for i in lmax:
y = y + str(i)
else:
j = m - 1
while j >= 0:
if sum2 - 9 <= s:
a = 9 - (sum2 - s)
lmax[j] = a
sum2 = sum2 + a - 9
break
else:
sum2 = sum2 - 9
lmax[j] = 0
j = j - 1
if sum2 == s:
for i in lmax:
y = y + str(i)
else:
flag = 0
print(-1, -1)
if flag == 1:
print(x, y)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER IF VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF 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 | def ans1(a, b):
if b == 0 and a != 1 or b > 9 * a:
return -1
p = ""
while b > 9:
p = p + "9"
b = b - 9
a = a - 1
if a == 0:
return p
else:
if a >= 2:
p = p + str(b - 1)
a = a - 1
p = p + "0" * (a - 1)
p = p + "1"
else:
p = p + str(b)
return p
def ans2(a, b):
if b == 0 and a != 1 or b > 9 * a:
return -1
p = ""
while b >= 9:
p = p + "9"
b = b - 9
a = a - 1
if a == 0:
return p
else:
p = p + str(b)
a = a - 1
p = p + "0" * a
return p
a, b = list(map(int, input().split()))
x = ans1(a, b)
if x != -1:
x = x[::-1]
y = ans2(a, b)
print(x, y) | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP STRING VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN 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 | piece = input().split()
length = int(piece[0])
digit = int(piece[1])
if length > 1 and digit < 1 or digit > 9 * length:
print(-1, -1)
exit()
tempt = ""
a, b = length, digit
for i in range(a):
if b >= 9:
tempt = tempt + "9"
b = b - 9
else:
tempt = tempt + str(b)
b = 0
big = tempt
tempt = ""
a, b = length, digit
for i in range(a):
if i == a - 1:
tempt = str(b) + tempt
continue
if b >= 10:
tempt = "9" + tempt
b = b - 9
else:
tempt = str(b - 1) + tempt
b = 1
small = tempt
print(small, big) | 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 BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN 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(" "))
c_s = s - 1
if s > m * 9 or s < 1 and m != 1:
print(-1, -1)
elif m == 1:
print(s, s)
else:
mx_c = []
for d in range(9, 0, -1):
while s >= d:
s -= d
mx_c.append(str(d))
for n in range(m - len(mx_c)):
mx_c.append("0")
mn_c = []
for d in range(9, 0, -1):
while c_s >= d:
c_s -= d
mn_c.insert(0, str(d))
for n in range(m - len(mn_c) - 1):
mn_c.insert(0, "0")
print(int("".join(mn_c)) + 10 ** (m - 1), int("".join(mx_c))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP NUMBER BIN_OP VAR NUMBER 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())
minans = []
maxans = []
m1 = 0
m2 = 0
if s > 9 * m:
minans.append(0)
maxans.append(0)
m1, m2 = -1, -1
elif s == 0:
if m == 1:
m1, m2 = 0, 0
else:
m1, m2 = -1, -1
else:
i = 1
num = 1
while num <= 9:
if num + (m - i) * 9 >= s - sum(minans):
minans.append(num)
m1 += num * pow(10, m - i)
break
num += 1
if m > 1:
i = 2
while i <= m:
num = 0
while num <= 9:
if num + (m - i) * 9 >= s - sum(minans):
minans.append(num)
m1 += num * pow(10, m - i)
break
num += 1
i += 1
j = 1
while j <= m:
num = 9
while num >= 0:
if num > s - sum(maxans):
pass
else:
maxans.append(num)
m2 += num * pow(10, m - j)
break
num -= 1
j += 1
print(m1, m2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR 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 | while True:
try:
m, s = [int(i) for i in input().split()]
if s == 0 and m == 1:
print("0 0")
elif s < 1 or s > 9 * m:
print("-1 -1")
else:
if 9 * (m - 1) >= s:
min = [1]
else:
min = [s - 9 * (m - 1)]
if s > 9:
max = [9]
else:
max = [s]
for i in range(m - 1):
m -= 1
s1 = s - sum(min)
s2 = s - sum(max)
if 9 * (m - 1) > s1:
min.append(0)
else:
min.append(s1 - 9 * (m - 1))
if s2 >= 9:
max.append(9)
else:
max.append(s2)
min = [str(i) for i in min]
max = [str(i) for i in max]
print("".join(min) + " " + "".join(max))
except EOFError:
break | WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL STRING VAR STRING FUNC_CALL STRING 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 | asdf = [int(x) for x in input().split(" ")]
length = asdf[0]
summ = asdf[1]
smallest = 0
largest = 0
if length * 9 < summ:
smallest = -1
largest = -1
elif summ < 1:
if length == 1:
smallest = 0
largest = 0
else:
smallest = -1
largest = -1
else:
smallestDigs = [1]
largestDigs = [1]
for i in range(1, length):
smallestDigs.append(0)
largestDigs.append(0)
currentSum = 1
currentIndex = length - 1
while currentSum < summ:
if summ - currentSum >= 9:
smallestDigs[currentIndex] = 9
currentSum += 9
else:
smallestDigs[currentIndex] = smallestDigs[currentIndex] + summ - currentSum
currentSum = summ
currentIndex -= 1
if summ <= 9:
largestDigs = [summ]
largestDigs.extend([(0) for k in range(1, length)])
else:
largestDigs[0] = 9
currentSum = 9
currentIndex = 1
while currentSum < summ:
if summ - currentSum >= 9:
largestDigs[currentIndex] = 9
currentSum += 9
else:
largestDigs[currentIndex] = summ - currentSum
currentSum = summ
currentIndex += 1
for i in range(length):
smallest += int(10 ** (length - 1 - i) * smallestDigs[i])
largest += int(10 ** (length - 1 - i) * largestDigs[i])
print(str(smallest) + " " + str(largest)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST VAR EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR 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 | n, s = map(int, input().split())
if s == 0 and n != 1:
print("-1", "-1")
elif n * 9 < s:
print("-1", "-1")
else:
a = [0] * n
b = [0] * n
i = 0
while sum(a) != s:
if sum(a) + 9 <= s:
a[i] = 9
else:
a[i] = s - sum(a)
i += 1
i = 0
s -= 1
while sum(b) != s:
if sum(b) + 9 <= s:
b[i] += 9
else:
b[i] += s - sum(b)
i += 1
b[-1] += 1
print("".join(str(i) for i in b[::-1]), "".join(str(i) for i in a)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR NUMBER 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 | s, m = map(int, input().split())
M = m
S = s
k = ""
max = 9 * s
min = 1
count = 0
dig = [9, 8, 7, 6, 5, 4, 3, 2, 1]
if min <= m <= max:
if m >= dig[0]:
l = dig[0]
else:
l = dig[9 - m]
while m != 0:
k += str(l)
m -= l
if m not in dig:
l = 9
else:
l = dig[9 - m]
m = l
c = len(k)
k += "0" * (s - c)
if k[-1] != "0":
print(k[::-1], k)
else:
ma = ""
dig.reverse()
l = 1
while M != 0:
ma += str(l)
M -= l
if M not in dig:
l = 9
else:
l = dig[M - 1]
M = l
c = len(ma)
ma += "0" * (s - c)
ma = list(map(int, list(ma)))
ma = ma[:1] + sorted(ma[1:])
ma = list(map(str, list(ma)))
ma = "".join(ma)
print(ma, k)
elif m == 0 and s == 1:
print(0, 0)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR WHILE VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP STRING BIN_OP VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP STRING BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR VAR 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 | n, m = [int(x) for x in input().split()]
if n == 1 and m == 0:
print(0, 0)
elif m < 1 or m > 9 * n:
print(-1, -1)
elif n == 1:
print(m, m)
elif n * 9 == m:
print("9" * n, "9" * n)
else:
t = m // 9
k = m % 9
k2 = k - 1
k = str(k)
k2 = str(k2)
l = n - t - 1
if l > 0:
if k == "0":
print("1" + "0" * l + "8" + "9" * (t - 1), "9" * t + k + "0" * l)
else:
print("1" + "0" * (l - 1) + k2 + "9" * t, "9" * t + k + "0" * l)
else:
print(k + "9" * t, "9" * t + k + "0" * l) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING VAR STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP STRING VAR VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER VAR BIN_OP STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR VAR BIN_OP STRING VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input 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 > a * 9:
print(-1, -1)
elif b == 0 and a == 1:
print(0, 0)
elif a > 1 and b == 0:
print(-1, -1)
else:
s = ""
while b != 0:
if b >= 9:
b = b - 9
s = s + str(9)
elif b >= 8:
b = b - 8
s = s + str(8)
elif b >= 7:
b = b - 7
s = s + str(7)
elif b >= 6:
b = b - 6
s = s + str(6)
elif b >= 5:
b = b - 5
s = s + str(5)
elif b >= 4:
b = b - 4
s = s + str(4)
elif b >= 3:
b = b - 3
s = s + str(3)
elif b >= 2:
b = b - 2
s = s + str(2)
elif b >= 1:
b = b - 1
s = s + str(1)
u = s[-1]
v = s[:-1]
t = a - len(s)
if t > 0:
s = s + "0" * (a - len(s))
if s[-1] != "0":
print(s[::-1], s)
else:
q = "1" + (t - 1) * "0" + str(int(u) - 1) + v
print(q, s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER 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 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 = [int(x) for x in input().split()]
if s == 0 and m == 1:
print(0, 0)
elif s < 1 or s > m * 9:
print(-1, -1)
else:
n = s
res1 = []
for i in range(0, m):
if s == 0:
res1.append(str(0))
elif s < 9:
res1.append(str(s))
s -= s
else:
res1.append(str(9))
s -= 9
res2 = []
s = n - 1
for i in range(0, m - 1):
if s == 0:
res2.append(str(0))
elif s < 9:
res2.append(str(s))
s -= s
else:
res2.append(str(9))
s -= 9
res2.append(str(s + 1))
res2.reverse()
print("".join(res2), end=" ")
print("".join(res1)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING EXPR 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 | def zip_sorted(a, b):
a, b = zip(*sorted(zip(a, b)))
sorted(zip(a, b), key=lambda x: x[1])
return a, b
m, s1 = [int(n1) for n1 in input().split()]
a = ["0"] * m
b = ["0"] * m
s = s1
for i in range(len(a)):
if s >= 9:
a[i] = "9"
s = s - 9
else:
a[i] = str(s)
s = 0
break
s = s1
for i in range(len(a)):
if s > 9:
b[m - 1 - i] = "9"
s = s - 9
elif 1 < s <= 9:
if m - 1 - i == 0:
b[m - 1 - i] = str(s)
break
else:
b[m - 1 - i] = str(s - 1)
s = 1
elif s == 1:
b[0] = str(int(b[0]) + 1)
break
sum1 = 0
sum2 = 0
for i in range(len(a)):
sum1 = int(a[i]) + sum1
sum2 = int(b[i]) + sum2
s = s1
if sum1 == sum2 == s and s != 0:
print("".join(b), "".join(a))
elif m == 1 and s == 0:
print(0, 0)
else:
print(-1, -1) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL STRING VAR 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 | m, s = [int(i) for i in input().split()]
a = s // 9
p = m - a
b = s % 9
if p == 0 and b == 0:
h = m * [9]
H = m * [9]
min = ""
max = ""
for i in h:
min += str(i)
for j in H:
max += str(j)
elif p == 1 and m != 1:
if b == 0:
h = [1] + [8] + (m - 2) * [9]
else:
h = [b] + (m - 1) * [9]
H = (m - 1) * [9] + [b]
min = ""
max = ""
for i in h:
min += str(i)
for j in H:
max += str(j)
elif p == 1 and m == 1:
max = min = s
elif 1 < p < m:
if b == 0:
h = [1] + (p - 1) * [0] + [8] + (m - p - 1) * [9]
else:
h = [1] + (p - 2) * [0] + [b - 1] + (m - p) * [9]
H = (m - p) * [9] + [b] + (p - 1) * [0]
min = ""
max = ""
for i in h:
min += str(i)
for j in H:
max += str(j)
elif p == m and b != 0:
if b == 1:
H = h = [1] + (m - 1) * [0]
if b > 1:
h = [1] + (m - 2) * [0] + [b - 1]
H = [b] + (m - 1) * [0]
min = ""
max = ""
for i in h:
min += str(i)
for j in H:
max += str(j)
else:
min = max = -1
print(min, max) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER LIST NUMBER LIST VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER LIST NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER LIST NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER LIST BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR LIST NUMBER LIST VAR BIN_OP BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER LIST NUMBER LIST BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN 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, s = map(int, input().split())
if n == 1 and s < 10:
print(s, s)
elif n == 1 or n * 9 < s or s == 0:
print(-1, -1)
else:
t, r = s, []
for _ in range(n):
r += [min(9, t)]
t -= min(9, t)
a = "".join(map(str, r))
r = r[::-1]
if r[0] == 0:
i = 1
while r[i] == 0:
i += 1
r[0] += 1
r[i] -= 1
while r[0] > 1 and r[1] < 9:
r[0], r[1] = r[0] - 1, r[1] + 1
for i in range(1, n - 1):
while r[i] > 0 and r[i + 1] < 9:
r[i], r[i + 1] = r[i] - 1, r[i + 1] + 1
print("".join(map(str, r)) + " " + a) | 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 BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR NUMBER NUMBER VAR VAR NUMBER WHILE VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL STRING FUNC_CALL VAR 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 = map(int, input().split(" "))
smallest, largest = [], []
if s == 0 and m > 1 or m * 9 < s:
print("-1 -1")
exit()
if s == 0 and m == 1:
print("0 0")
exit()
if m * 9 == s:
smallest = largest = ["9"] * (s // 9)
else:
s_small, s_large = s, s
if m % 9 > 0 or s % 9 > 0:
while s_small > 9:
smallest.append("9")
s_small -= 9
if len(smallest) < m - 1:
smallest.insert(0, "1")
s_small -= 1
smallest.insert(1, str(s_small))
while len(smallest) < m:
smallest.insert(1, "0")
else:
smallest.insert(0, str(s_small))
else:
while s_small:
smallest.append("9")
if len(smallest) < m:
smallest.remove("9")
smallest.insert(0, "1")
smallest.insert(1, "8")
while len(smallest) < m:
smallest.insert(1, "0")
while len(largest) < m:
if s_large >= 9:
largest.append("9")
s_large -= 9
else:
largest.append(str(s_large))
s_large = 0
print("".join(smallest) + " " + "".join(largest)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST LIST IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP LIST STRING BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER STRING WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER STRING WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN 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 | m, s = [int(i) for i in input().split()]
if s > 9:
t = s % 9
n = s // 9
if m > n:
large = int(n * "9" + str(t) + (m - n - 1) * "0")
if m > n + 1 or t == 0:
if t != 0:
small = int("1" + (m - n - 2) * "0" + str(t - 1) + n * "9")
else:
small = int("1" + (m - n - 1) * "0" + str(8) + (n - 1) * "9")
else:
small = int(str(t) + n * "9")
elif m == n and t == 0:
large = int(m * "9")
small = large
else:
large = "-1"
small = large
elif s == 0 and m != 1:
large = "-1"
small = large
elif s <= 9 and m == 1:
large = int(s)
small = large
else:
large = int(str(s) + (m - 1) * "0")
small = int("1" + (m - 2) * "0" + str(s - 1))
print(small, large) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR VAR NUMBER STRING FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR STRING IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER STRING FUNC_CALL 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 | import sys
def get_ints():
return map(int, sys.stdin.readline().strip().split())
m, s = get_ints()
if s == 0 and m == 1:
print("0 0")
elif s == 0 or s > 9 * m:
print("-1 -1")
elif m == 1:
print(str(s) + " " + str(s))
elif s == 1:
print(str(1) + "0" * (m - 1) + " " + str(1) + "0" * (m - 1))
elif s == 9 * m:
print("9" * m + " " + "9" * m)
else:
largest = ""
largest_s = s
while largest_s > 9:
largest += str(9)
largest_s -= 9
largest += str(largest_s)
largest = largest + "0" * (m - len(largest))
smallest = ""
smallest_s = s
if s <= 9 * (m - 1):
smallest = "1"
smallest_s -= 1
smallest += "0" * (m - int(smallest_s / 9) - 2)
smallest += str(smallest_s % 9)
smallest += "9" * int(smallest_s / 9)
print(smallest + " " + largest) | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER STRING FUNC_CALL VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR STRING BIN_OP STRING VAR ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING VAR NUMBER VAR BIN_OP STRING BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP STRING FUNC_CALL VAR 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 | import sys
d, s = map(int, sys.stdin.readline().split())
w, h = s + 1, d + 1
m = [[(-1) for x in range(w)] for y in range(h)]
n = [[(-1) for x in range(w)] for y in range(h)]
for i in range(1, min(9, s) + 1):
n[1][i] = m[1][i] = i
n[1][0] = 0
m[1][0] = 0
for i in range(2, d + 1):
for j in range(1, min(9 * i, s) + 1):
if j - 9 >= 1:
m[i][j] = m[i - 1][j - 9] * 10 + 9
else:
m[i][j] = m[i - 1][1] * 10 + (j - 1)
if n[i - 1][j] > 0:
n[i][j] = n[i - 1][j] * 10
else:
n[i][j] = n[i][j - 1] + 1
print(m[d][s], n[d][s]) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP 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 | a = list(input().split(" "))
m = int(a[0])
s = int(a[1])
if s == 0 or s > 9 * m:
if m == 1 and s == 0:
print("0 0")
else:
print("-1 -1")
else:
b = m * [0]
c = s // 9
d = s % 9
for i in range(0, c):
b[i] = 9
if c != m:
b[c] = d
e = m * [0]
for i in range(0, m):
e[i] = b[m - i - 1]
if e[0] == 0:
e[0] = 1
if d != 0:
e[m - c - 1] -= 1
else:
e[m - c] -= 1
for i in range(0, m):
b[i] = str(b[i])
e[i] = str(e[i])
p = "".join(b)
q = "".join(e)
print("%d %d" % (int(q), int(p))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP 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 | n = input()
a, b = n.split()
if int(b) >= 1 and int(b) <= 9 * int(a) or int(b) == 0 and int(a) == 1:
x = 1
y = 1
c = []
g = []
while x <= int(a):
if int(b) - 9 * x >= 1:
x += 1
else:
d = int(b) - 9 * (x - 1)
if int(a) > x:
c.append("1")
while y <= int(a) - x - 1:
c.append("0")
y += 1
y = 1
c.append(str(d - 1))
while y <= x - 1:
c.append("9")
y += 1
e = "".join(c)
c.reverse()
c[x - 1] = str(d)
c[-1] = "0"
f = "".join(c)
if int(b) == 1:
print(e + " " + e)
elif x == 1:
g.append(str(d))
while y <= int(a) - x - 1:
g.append("0")
y += 1
g.append("0")
h = "".join(g)
print(e + " " + h)
else:
print(e + " " + f)
break
else:
c.append(str(d))
while y <= x - 1:
c.append("9")
y += 1
e = "".join(c)
c.reverse()
f = "".join(c)
print(e + " " + f)
break
else:
print("-1 -1") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING WHILE VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR 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 can(l, s):
if s >= 0 and s <= 9 * int(l):
return True
else:
return False
l, s = map(int, input().split())
f = s
ans = ""
if can(l, s) == False or s == 0 and l > 1:
print(-1, -1)
exit()
for i in range(l):
for d in range(0, 10):
if (i > 0 or d > 0 or l == 1 and s == 0) and can(l - i - 1, s - d) == True:
ans += str(d)
s -= d
break
print(ans, end=" ")
y = ""
for i in range(l):
for d in range(9, -1, -1):
if can(l - i - 1, f - d) == True:
y += str(d)
f -= d
break
print(y) | FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER 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 | m, s = 1, 0
m, s = [int(x) for x in input().split(" ")]
if s == 0 and m != 1 or m * 9 < s:
print("-1 -1")
exit(0)
target = s
result_max = ""
for i in range(m):
for digit in reversed(range(0, 10)):
if target >= digit:
target -= digit
result_max += str(digit)
break
if target == 0:
break
if len(result_max) != i + 1:
result_max += "0"
target = s
result_min = ""
for i in range(m):
for digit in reversed(range(0, 10)):
if target - 1 >= digit:
target -= digit
result_min = str(digit) + result_min
break
if target == 0:
break
if len(result_min) != i + 1:
result_min = "0" + result_min
if target == 1:
result_min = str(int(result_min[0]) + 1) + result_min[1:]
print("{} {}".format(result_min, result_max)) | ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING 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())
msmallest, slargest = m, s
if s / m > 9 or m > 1 and s == 0:
print("-1 -1")
else:
if s > 9:
totaln = s // 9
s -= 9 * totaln
msmallest -= totaln
else:
totaln = 0
smallest = ""
for i in range(msmallest):
if i == 0 and msmallest > 1:
smallest += "1"
s -= 1
elif i > 0 and i != msmallest - 1:
smallest += "0"
else:
smallest += str(s)
smallest += "9" * totaln
if "-1" in smallest:
smallest = smallest.replace("-19", "08")
largest = ""
for i in range(m):
if slargest >= 9:
largest += str(9)
slargest -= 9
else:
largest += str(slargest)
slargest -= slargest
print(f"{smallest} {largest}") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR STRING VAR FUNC_CALL VAR VAR VAR BIN_OP STRING VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR 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 | ms = input().split()
ms = [int(i) for i in ms]
m = ms[0]
s = ms[1]
if s > 9 * m or s == 0 and m != 1:
print("-1 -1")
elif s == 0 and m == 1:
print("0 0")
else:
numbers = []
for i in range(m):
if s > 9:
numbers.append("9")
s -= 9
else:
numbers.append(str(s))
s = 0
max1 = "".join(numbers)
zeros = 0
while "0" in numbers:
zeros += 1
numbers.remove("0")
numbers.sort()
if zeros != 0:
numbers[0] = str(int(numbers[0]) - 1)
numbers.insert(0, "1")
for i in range(zeros - 1):
numbers.insert(1, "0")
min1 = "".join(numbers)
print(min1, max1) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER WHILE STRING VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL 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 | x, y = map(int, input().split())
a = y // 9
p = "9" * a
q = p + str(y - a * 9) + "0" * (x - (a + 1))
if x == 1 and y == 0:
print(0, 0)
exit()
elif y / 9 > x or x > 1 and y == 0:
print(-1, -1)
exit()
elif y % 9 == 0 and len(q) > x:
r = q[::-1]
r = r.replace(r[0], "")
q = q.replace(q[x], "")
elif q[::-1][0] == "0":
r = "1" + "0" * (x - (a + 2)) + str(y - a * 9 - 1) + p
if y % 9 == 0:
r = "1" + "0" * (x - (a + 1)) + "8" + "9" * (a - 1)
else:
r = q[::-1]
print(r, q) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER NUMBER STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN 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 | z = input().split()
m = int(z[0])
s = int(z[1])
if s > 9 * m:
print(-1, -1)
elif s == 0 and m == 1:
print(0, 0)
elif s < 1:
print(-1, -1)
elif m == 1:
print(s, s)
elif m * 9 == s:
print("9" * m, "9" * m)
else:
maximum = "9" * int(s / 9)
maximum += str(s % 9)
maximum += "0" * (m - int(s / 9) - 1)
minimum = list(maximum[::-1])
if minimum[0] == "0":
minimum[m - maximum.find("0")] = int(minimum[m - maximum.find("0")]) - 1
minimum[0] = "1"
for i in minimum:
print(i, end="")
print(" ", maximum) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR 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 IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP STRING BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input 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, m = map(int, input().split())
isTrue = False
if s == 100:
b_low = int("1".ljust(len(str(s)) + s - 3, "0"))
b_high = int("9".ljust(len(str(s)) + s - 3, "9"))
elif s < 10:
b_low = int("1".ljust(len(str(s)) + s - 1, "0"))
b_high = int("9".ljust(len(str(s)) + s - 1, "9"))
else:
b_low = int("1".ljust(len(str(s)) + s - 2, "0"))
b_high = int("9".ljust(len(str(s)) + s - 2, "9"))
if s == 1 and m == 0:
print(f"{0} {0}")
else:
for i in range(s - 1, -1, -1):
for n in range(1, 10):
if sum(list(map(int, str(b_low)))) == m:
break
b_low = int(str(b_low)[:i] + str(n) + str(b_low)[i + 1 :])
if sum(list(map(int, str(b_low)))) == m:
break
for i in range(s - 1, -1, -1):
for n in range(9, -1, -1):
if sum(list(map(int, str(b_high)))) == m:
isTrue = True
break
b_high = int(str(b_high)[:i] + str(n) + str(b_high)[i + 1 :])
if (
sum(list(map(int, str(b_high)))) == m
and not sum(list(map(int, str(b_high)))) == 0
):
isTrue = True
break
if sum(list(map(int, str(b_high)))) == m:
break
if isTrue:
print(f"{b_low} {b_high}")
else:
print(f"{-1} {-1}") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR NUMBER STRING 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 = [int(i) for i in input().split()]
if s > m * 9:
print("-1 -1")
elif s == 0:
if m == 1:
print("0 0")
else:
print("-1 -1")
else:
Max = []
n9 = s // 9
if n9 > 0:
for i in range(n9):
Max.append(9)
others = s - 9 * n9
if others > 0:
Max.append(others)
n0 = m - len(Max)
if n0 > 0:
for i in range(n0):
Max.append(0)
N9 = (s - 1) // 9
if m == N9 + 1:
first = s - 9 * N9
Min = [first]
if N9 > 0:
for i in range(N9):
Min.append(9)
else:
Others = s - 1 - 9 * N9
N0 = m - N9 - 2
if n0 > 0:
Min = [1]
for i in range(N0):
Min.append(0)
Min.append(Others)
for i in range(N9):
Min.append(9)
else:
Min = [1, Others]
for i in range(N9):
Min.append(9)
xiao = []
for i in Min:
xiao.append(str(i))
da = []
for i in Max:
da.append(str(i))
print("".join(xiao), end=" ")
print("".join(da)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR LIST VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING EXPR 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 | from sys import stderr, stdin
def readInts():
return map(int, stdin.readline().strip().split())
def print_err(*args, **kwargs):
print(*args, file=stderr, **kwargs)
def solve(m, s):
if m == 1 and s == 0:
return "0", "0"
if s == 1:
out = str(10 ** (m - 1))
return out, out
def toOut(ns):
return "".join(map(str, ns))
bad = "-1", "-1"
m2, s2 = m, s
rhs_rev = []
while s2 > 10:
rhs_rev.append(9)
s2 -= 9
m2 -= 1
if m2 < 0:
return bad
if m2 <= 1:
if s2 > 9:
return bad
if m2 == 1 and s2 > 0:
rhs_rev.append(s2)
if m2 == 0 and s2 > 0:
return bad
rhs_rev = toOut(rhs_rev)
return rhs_rev[::-1], rhs_rev
largest_rev = rhs_rev[::-1]
m2large = m2
if s2 < 1:
return bad
if s2 == 10:
largest_rev.append(9)
largest_rev.append(1)
m2large -= 2
else:
largest_rev.append(s2)
m2large -= 1
while m2large > 0:
largest_rev.append(0)
m2large -= 1
largest = largest_rev[::-1]
rhs_rev.append(s2 - 1)
s2 = 1
m2 -= 1
while m2 > 1:
rhs_rev.append(0)
m2 -= 1
rhs_rev.append(1)
m2 -= 1
if m2large < 0 or m2 < 0:
return bad
rhs_rev = toOut(rhs_rev)
largest_rev = toOut(largest_rev)
return rhs_rev[::-1], largest_rev
def run():
m, s = readInts()
print(" ".join(solve(m, s)))
def test():
for m in range(1, 4):
for s in range(40):
print(m, s, solve(m, s))
run() | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR STRING STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR 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 | m, s = map(int, input().split())
if s:
x = [1]
y = [9]
for i in range(m - 1):
x.append(0)
y.append(9)
sx = 1
sy = m * 9
for i in range(1, m, 1):
if abs(sy - s) > 9 and sy - s:
y[m - i] -= 9
sy -= 9
elif sy - s:
y[m - i] -= abs(sy - s)
sy = s
if abs(s - sx) > 9 and s - sx:
x[m - i] += 9
sx += 9
elif s - sx:
x[m - i] += abs(s - sx)
sx = s
if abs(s - sy) > 8 and sy - s:
y[0] -= 8
sy -= 8
elif sy - s:
y[0] -= abs(s - sy)
sy = s
if abs(s - sx) > 8 and s - sx:
x[0] += 8
sx += 8
elif s - sx:
x[0] += abs(s - sx)
sx = s
x, y = map(str, x), map(str, y)
x, y = "".join(x), "".join(y)
if s == sx:
print(x, y)
else:
print("-1 -1")
elif m == 1:
print("0 0")
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL STRING VAR FUNC_CALL STRING VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF 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 = input().split()
if int(s) == 0 and int(m) == 1:
print("0 0")
elif int(s) < 1 or int(s) > 9 * int(m):
print("-1 -1")
else:
small = pow(10, int(m) - 1)
large = small * 10 - 1
a = sum(map(int, str(small)))
b = sum(map(int, str(large)))
k = 1
d = int(s) - a
while d > 0:
if d > 9:
small += k * 9
d = d - 9
else:
small += k * d
d = 0
k = k * 10
dl = b - int(s)
j = 1
while dl > 0:
if dl <= 9:
large -= j * dl
dl = 0
else:
large -= j * 9
dl -= 9
j = j * 10
print(small, end=" ")
print(large) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR WHILE VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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 | m, s = map(int, input().split())
if m > 1 and s == 0 or 9 * m < s:
print(-1, -1)
elif s <= 9:
if m >= 2:
print("1" + "0" * (m - 2) + str(s - 1), str(s) + "0" * (m - 1))
else:
print(s, s)
else:
k = s // 9
if k == m:
print("9" * k, "9" * k)
else:
l = s % 9
n = m - k
if n == 1:
print(str(l) + "9" * k, "9" * k + str(l))
elif n != 1 and l == 0:
print("1" + "0" * (n - 1) + "8" + "9" * (k - 1), "9" * k + "0" * n)
else:
x = l - 1
print(
"1" + "0" * (n - 2) + str(x) + "9" * k, "9" * k + str(l) + "0" * (n - 1)
) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER 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 EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP VAR NUMBER |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input 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 = input("").split()
m = int(m)
s = int(s)
if s > m * 9 or s == 0 and m != 1:
print("-1 -1")
elif s == 0 and m == 1:
print("0 0")
else:
x, k, p = 0, 0, 1
n = int(10 ** (m - 1))
while s > 9:
p = 10 * p
k = k + 1
x = 9 * n + x
n = 10 ** (m - k - 1)
s = s - 9
x = int(s * n + x)
if len(str(x)) < m:
print(m - len(str(x)))
x = int(x * 10 ** (m - len(str(x))))
y = str(int(x))[::-1]
if y[0] == "0":
y = int(y) + 10 ** (m - 1) - p
print(int(y), int(x)) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER 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 minum(s: int, l: int) -> str:
if s == 0 and l == 1:
return "0"
if s == 0:
return "-1"
res = ""
for i in range(l - 1):
if s > 10:
res = res + "9"
s = s - 9
continue
if s > 1:
res = res + str(s - 1)
s = 1
continue
if s == 1:
res = res + "0"
if s > 9:
return "-1"
res = res + str(s)
return res[::-1]
def manum(s: int, l: int) -> str:
if s == 0 and l == 1:
return "0"
if s == 0:
return "-1"
res = ""
for i in range(l):
if s > 9:
res = res + "9"
s = s - 9
continue
if s > 0:
res = res + str(s)
s = 0
continue
if s == 0:
res = res + "0"
if s != 0:
return "-1"
res = res
return res
a, b = map(int, input().split())
print(minum(b, a), manum(b, a)) | FUNC_DEF VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER RETURN STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF VAR NUMBER RETURN STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR NUMBER VAR FUNC_DEF VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER RETURN STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF VAR NUMBER RETURN STRING ASSIGN VAR VAR RETURN VAR 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 | import sys
s, m = map(int, input().split())
maxi = ""
sume = 0
for i in range(1, s + 1):
if m - sume - 9 > s - i:
maxi += "9"
sume += 9
elif i == s:
maxi += str(m - sume)
sume += m - sume
else:
for j in range(9, -1, -1):
if j <= m - sume:
maxi += str(j)
sume += j
break
mini = ""
if sume != m or len(maxi) > s:
print(-1, -1, sep=" ")
sys.exit()
sume = 0
for i in range(1, s + 1):
if i == 1:
if m - sume + 1 <= (s - i) * 9:
mini += "1"
sume += 1
continue
if m - sume <= (s - i) * 9:
mini += "0"
sume += 0
elif i == s:
mini += str(m - sume)
sume += m - sume
else:
for j in range(10):
if m - sume - j <= (s - i) * 9:
mini += str(j)
sume += j
break
if sume != m or len(mini) > s:
print(-1, -1, sep=" ")
sys.exit()
print(mini, maxi, sep=" ") | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR STRING VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING IF VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR STRING VAR NUMBER IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR STRING VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER STRING EXPR FUNC_CALL 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())
largest = [9] * m
smallest = [1] + [0] * (m - 1)
largestSum = 9 * m
smallestSum = 1
if s == 0 and m == 1:
print("0 0")
exit()
if not (s >= smallestSum and s <= largestSum):
print("-1 -1")
exit()
for i in range(m)[::-1]:
if largestSum > s:
remaining = largestSum - s
largest[i] = 9 - min(9, remaining)
largestSum -= 9 - largest[i]
if smallestSum < s:
if i == 0:
smallestSum -= 1
remaining = s - smallestSum
smallest[i] = min(9, remaining)
smallestSum += smallest[i]
if smallestSum == s and largestSum == s:
print("".join(map(str, smallest)), "".join(map(str, largest)))
break
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER VAR VAR BIN_OP NUMBER VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR 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 | inp = input()
s = inp.split()
try:
m = int(s[0])
n = int(s[1])
except:
print("Please enter digits between 1 & 100")
quit()
c9 = 0
text9 = "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
text0 = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
sm = 0
smm = 0
if m > 1 and n == 0:
print("-1", "-1")
quit()
if m == 0:
print("-1", "-1")
quit()
if m <= 2:
if m == 1:
outl = n
outs = n
for nnn in str(outl):
sm = sm + int(nnn)
for nn in str(outs):
smm = smm + int(nn)
if sm == n and smm == n and len(str(outl)) == len(str(outs)) == m:
print(outs, outl)
quit()
else:
print("-1", "-1")
quit()
if m == 2:
if n >= 9:
outl = "9" + str(n - 9)
outs = str(n - 9) + "9"
for nnn in str(outl):
sm = sm + int(nnn)
for nn in str(outs):
smm = smm + int(nn)
if sm == n and smm == n and len(str(outl)) == len(str(outs)) == m:
print(outs, outl)
quit()
else:
print("-1", "-1")
quit()
if n < 9:
outs = "1" + str(n - 1)
outl = str(n) + "0"
for nnn in str(outl):
sm = sm + int(nnn)
for nn in str(outs):
smm = smm + int(nn)
if sm == n and smm == n and len(str(outl)) == len(str(outs)) == m:
print(outs, outl)
quit()
else:
print("-1", "-1")
quit()
elif m > 2:
if n > 9:
s = n
while s > 9:
s = s - 9
c9 = c9 + 1
outl = text9[:c9] + str(s) + text0[: m - (c9 + 1)]
if m - c9 == 1:
outs = str(s) + text9[:c9]
elif m - c9 >= 2:
outs = "1" + text0[: m - (c9 + 2)] + str(s - 1) + text9[:c9]
for nnn in str(outl):
sm = sm + int(nnn)
for nn in str(outs):
smm = smm + int(nn)
if sm == n and smm == n and len(str(outl)) == len(str(outs)) == m:
print(outs, outl)
quit()
else:
print("-1", "-1")
quit()
if n <= 9:
outl = str(n) + text0[: m - 1]
outs = "1" + text0[: m - 2] + str(n - 1)
for nnn in str(outl):
sm = sm + int(nnn)
for nn in str(outs):
smm = smm + int(nn)
if sm == n and smm == n and len(str(outl)) == len(str(outs)) == m:
print(outs, outl)
quit()
else:
print("-1", "-1")
quit() | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL 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 | a, b = map(int, input().split())
sm = [0] * a
la = [0] * a
b1 = b
b2 = b
for i in range(a):
la[i] = min(9, b1)
b1 -= min(9, b1)
sm[a - i - 1] = min(9, b2)
b2 -= min(9, b2)
t = 1
if sm[0] == 0:
t = 0
for i in range(1, a):
if sm[i] != 0:
sm[i] -= 1
sm[0] += 1
t = 1
break
if a == 1 and b == 0:
print(0, 0)
elif b2 != 0 and b1 != 0:
print(-1, -1)
elif t == 0:
if b != 0:
print(-1, *la, sep="")
else:
print(-1, -1)
elif b != 0:
print(*sm, " ", *la, sep="") | 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 ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR STRING EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING 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 9 * m >= s and s > 0:
a = ""
b = ""
for i in range(m):
if s >= 9:
a += "9"
s -= 9
else:
a += str(s)
s = 0
if a.count("0") > 0:
b = (
a[: a.find("0") - 1]
+ str(int(a[a.find("0") - 1]) - 1)
+ a[a.find("0") : len(a) - 1]
)
b = "1" + b[::-1]
else:
b = a[::-1]
print(b, a)
elif s == 0 and m == 1:
print(0, 0)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR 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 | line = input().split()
m = int(line[0])
s = int(line[1])
if s == 0 and m != 1 or s > 9 * m:
print(-1, -1)
elif m == 1:
print(s, s)
else:
y9 = (9 * m - s) % 9
n9 = (9 * m - s) // 9
re = str(9 - y9)
nmax = "9" * (m - n9 - 1) + re + "0" * n9
if nmax[m - 1] != "0":
nmin = nmax[::-1]
print(int(nmin), int(nmax))
elif y9 != 0:
re = str(8 - y9)
nmin = "1" + "0" * (n9 - 1) + re + "9" * (m - n9 - 1)
print(int(nmin), int(nmax))
else:
nmin = "1" + "0" * (n9 - 1) + "8" + "9" * (m - n9 - 1)
print(int(nmin), int(nmax)) | 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 BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP STRING VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input 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, s = map(int, input().split())
if a == 1 and s == 0:
print(0, 0)
elif s < 1 or 9 * a < s:
print(-1, -1)
else:
ans = ["0"] * a
t = s
for i in range(len(ans) - 1, 0, -1):
if t >= 10:
t -= 9
ans[i] = "9"
else:
ans[i] = str(t - 1)
ans[0] = "1"
break
else:
ans[0] = str(t)
print("".join(ans), end=" ")
ans = ["0"] * a
t = s
for i in range(len(ans)):
if t >= 9:
t -= 9
ans[i] = "9"
else:
ans[i] = str(t)
break
print("".join(ans)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR EXPR 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 | a = input()
if a == "1 0":
print(int(0), int(0))
else:
b = a.split()
m = int(b[0])
s = int(b[1])
p = m
q = s
r = 0
summax = 0
summin = 0
if s == 0:
print(int(-1), int(-1))
elif s > m * 9:
print(int(-1), int(-1))
else:
while q > 9:
q = q - 9
r = r + 1
for i in range(r):
summax = summax + 9 * 10 ** (p - i - 1)
summax = summax + q * 10 ** (p - r - 1)
p = m
q = s
r = 0
while q > 9:
q = q - 9
r = r + 1
for i in range(r):
summin = summin + 9 * 10**i
summin = summin + 1 * 10 ** (m - 1) + (q - 1) * 10**r
print(summin, summax) | ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER 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())
m1, s1 = m, s
a, b = [], []
if m * 9 < s or s == 0 and m != 1:
print("-1 -1")
elif s == 1:
print("1" + "0" * (m - 1), "1" + "0" * (m - 1))
elif m == 1:
print(s, s)
elif m > 1:
if s - 1 < (m - 1) * 9:
b.append("1")
s -= 1
if s % 9 != 0:
b.append(str(s % 9))
s -= s % 9
while s > 9:
b.append("9")
s -= 9
if s != 0:
b.append(str(s))
print(b[0] + "0" * (m1 - len(b)) + "".join(b[1:]), end=" ")
s = s1
while s > 9:
a.append("9")
s -= 9
a.append(str(s))
print("".join(a) + "0" * (m1 - len(a))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR LIST LIST IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL STRING VAR NUMBER STRING ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING VAR BIN_OP STRING BIN_OP 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 = map(int, input().split())
if 9 * m < s or s == 0 and m > 1:
print(-1, -1)
elif s == 0 and m == 1:
print(0, 0)
else:
mx = []
i = 9
sm = s
signs = 0
while s:
while s - i >= 0:
mx.append(i)
signs += 1
s -= i
i -= 1
while signs < m:
mx.append(0)
signs += 1
mn = []
i = 9
signs = 0
while sm:
while sm - i >= 0:
mn.append(i)
signs += 1
sm -= i
i -= 1
if m - signs:
mn[-1] -= 1
while m - signs > 1:
mn.append(0)
signs += 1
mn.append(1)
for i in range(len(mn) - 1, -1, -1):
print(mn[i], end="")
print(" ", end="")
for i in mx:
print(i, end="") | 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING 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())
if s == 0 and m != 1 or 9 * m < s:
print(-1, -1)
else:
l = s // 9
k = s % 9
ma = "9" * l
if m - l > 0:
ma = ma + str(k)
ma = ma + "0" * (m - l - 1)
mi = 10 ** ((s - 1) // 9) * ((s - 1) % 9 + 1) - 1 + 10 ** (m - 1)
print(int(mi), ma) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR 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 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 | length, summary = map(int, input().split(" "))
def can(m, s):
if s >= 0 and s <= 9 * m:
return True
return False
def searchMin(s, length):
minn = ""
for i in range(length):
for d in range(10):
if (i > 0 or d > 0 or length == 1 and d == 0) and can(
length - i - 1, s - d
):
minn += str(d)
s -= d
break
return str(minn)
def searchMax(s, length):
maxx = ""
for i in range(length):
for d in range(9, -1, -1):
if (i > 0 or d > 0 or length == 1 and d == 0) and can(
length - i - 1, s - d
):
maxx += str(d)
s -= d
break
return str(maxx)
mn = searchMin(summary, length)
mx = searchMax(summary, length)
if mn == "":
mn = "-1"
if mx == "":
mx = "-1"
if length == 1 and summary == 0:
print("0 0")
elif length > 1 and summary == 0:
print("-1 -1")
else:
print(mn + " " + mx) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR 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 RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR 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 RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING 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 | m, s = map(int, input().split())
a, b = "", ""
if s > 9 * m:
print("-1 -1")
elif s == 0 and m != 1:
print("-1 -1")
elif s == 0 and m == 1:
print("0 0")
elif m == 1:
print(str(s) + " " + str(s))
else:
if s % 9 == 0:
b = "9" * (s // 9) + "0" * (m - s // 9)
else:
b = "9" * (s // 9) + str(s % 9) + "0" * max(0, m - s // 9 - 1)
if s // 9 >= m - 1:
a = b[::-1]
else:
a = (
"1"
+ "0" * max(0, m - (s - 1) // 9 - 2)
+ str((s - 1) % 9)
+ "9" * ((s - 1) // 9)
)
print(a + " " + b) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING STRING IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP STRING FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER 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 | m, s = [int(i) for i in input().split()]
if s == 0 and m != 1 or s > m * 9:
print(-1, -1)
exit()
if s == 0 and m == 1:
print(0, 0)
exit()
minans = [1] + [0] * (m - 1)
maxans = [1] + [0] * (m - 1)
tmp = s - 1
for i in range(m - 1, -1, -1):
if tmp >= 9 - minans[i]:
tmp -= 9 - minans[i]
minans[i] = 9
else:
minans[i] += tmp
break
tmp = s - 1
for i in range(0, m):
if tmp >= 9 - maxans[i]:
tmp -= 9 - maxans[i]
maxans[i] = 9
else:
maxans[i] += tmp
break
print("".join([str(i) for i in minans]), "".join([str(i) for i in maxans])) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR 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 | m, s = list(map(int, input().split()))
def can(m, s):
return s >= 0 and s <= 9 * m
sum_ = s
min_ = ""
for i in range(m):
for d in range(10):
if (i > 0 or d > 0 or m == 1 and d == 0) and can(m - i - 1, sum_ - d):
min_ += str(d)
sum_ -= d
break
sum_ = s
max_ = ""
for i in range(m):
for d in range(9, -1, -1):
if (i > 0 or d > 0 or m == 1 and d == 0) and can(m - i - 1, sum_ - d):
max_ += str(d)
sum_ -= d
break
if min_.count("0") == len(min_) and min_.count("0") > 1 or min_ == "" or len(min_) < m:
print(-1, -1)
else:
print(min_, max_) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR 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 ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR 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 IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER VAR STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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 | n, m = map(int, input().split())
if 1 <= m <= n * 9:
a = [0] * n
j = n - 1
i = m - 1
while j > 0:
if i > 9:
a[j] = 9
i -= 9
else:
a[j] = i
i -= i
j -= 1
a[0] = i + 1
s = [str(i) for i in a]
print("".join(s), end=" ")
i = m
j = 0
while j < n:
j += 1
if i > 9:
print(9, end="")
i -= 9
else:
print(i, end="")
i -= i
elif n == 1 and m == 0:
print("0 0")
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR STRING 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 | S = input().split()
m = int(S[0])
s = int(S[1])
M = []
if s == 0 and m > 1 or 9 * m < s:
print(-1, -1)
else:
for i in range(m):
if s >= 9:
num = 9
else:
num = s
M.append(str(num))
s = s - num
m = m - 1
max = "".join(M)
M.reverse()
if int(M[0]) == 0:
for i in range(1, len(M)):
if int(M[i]) > 0:
M[i] = str(int(M[i]) - 1)
M[0] = str(1)
break
min = "".join(M)
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 LIST IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL STRING 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 | def generate1(long, sum1):
if 9 * long >= sum1 and sum1 >= 1 or long == 1 and sum1 == 0:
if long == 1 and sum1 >= 1 and sum1 <= 9:
return sum1
elif sum1 > 9:
sum1 -= 9
long -= 1
return generate1(long, sum1) + 9 * pow(10, long)
elif sum1 <= 9:
long -= 1
return sum1 * pow(10, long)
else:
return -1
def generate2(long, sum1):
if 9 * long >= sum1 and sum1 >= 1 or long == 1 and sum1 == 0:
if sum1 > 9:
sum1 -= 9
long -= 1
return generate2(long, sum1) * 10 + 9
if sum1 <= 9:
return sum1 - 1 + 1 * pow(10, long - 1)
else:
return -1
x = [int(i) for i in input().split()]
print("%d %d" % (generate2(x[0], x[1]), generate1(x[0], x[1]))) | FUNC_DEF IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR NUMBER VAR RETURN NUMBER FUNC_DEF IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER VAR NUMBER 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 m > 1 and s == 0 or m * 9 < s:
print(-1, -1)
elif m == 1 and s == 0:
print(0, 0)
else:
a = []
for i in range(m):
if (s - 9 * i) // 9 > 0:
a.append("9")
else:
a.append(str(s - 9 * i))
a.append("0" * (m - 1 - i))
break
max = "".join(a)
b = list(max)[::-1]
if b[0] != "0":
min = "".join(b)
else:
for i in range(m):
if b[i] != "0":
b[i] = str(int(b[i]) - 1)
break
b[0] = "1"
min = "".join(b)
print(min, max) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER STRING ASSIGN VAR FUNC_CALL 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 | n, m = map(int, input().strip().split())
num = ""
sumi = m
if n == 1 and m == 0:
print(0, 0)
else:
while sumi:
if sumi >= 9:
num += "9"
sumi -= 9
else:
num += str(sumi)
sumi = 0
if len(num) > n or n == 0 or m == 0:
print(-1, -1)
else:
ans1 = num + "0" * (n - len(num))
ans2 = ""
if len(num) == n:
ans2 = "".join(num[i] for i in range(n - 1, -1, -1))
else:
num = num[:-1] + str(int(num[-1]) - 1)
ans2 = (
"1"
+ "0" * (n - (len(num) + 1))
+ "".join(num[i] for i in range(len(num) - 1, -1, -1))
)
print(ans2, ans1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER WHILE VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 | d, s = [int(x) for x in input().split()]
init_d = d
dic = {}
def f(d, s, dic):
if (d, s) in dic:
return dic[d, s]
if d == 1 and 0 <= s <= 9:
dic[d, s] = s, s
return s, s
if d == 1 and (s < 0 or s > 9):
dic[d, s] = -1, -1
return -1, -1
mini = float("inf")
maxi = float("-inf")
start = 1 if init_d == d else 0
for v in range(start, 10):
a, b = f(d - 1, s - v, dic)
if a != -1:
mini = min(v * 10 ** (d - 1) + a, mini)
break
for v in range(9, start - 1, -1):
a, b = f(d - 1, s - v, dic)
if b != -1:
maxi = max(v * 10 ** (d - 1) + b, maxi)
break
if mini == float("inf"):
mini = -1
if maxi == float("-inf"):
maxi = -1
dic[d, s] = maxi, mini
return mini, maxi
a, b = f(d, s, dic)
print(a, b) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR RETURN VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER RETURN NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR IF VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR RETURN VAR VAR ASSIGN 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 | m, s = map(int, input().split())
ans = []
flag = 0
temp = 0
if s != 0:
while s >= 0 and (s // 9 < m or s // 9 == m and s % 9 == 0) and temp < m:
flag = 1
temp += 1
if s - 9 > 0:
ans.append(9)
s -= 9
else:
ans.append(s)
s = 0
continue
if s == 0 and temp < m:
ans.append(0)
if flag:
ans1 = "".join(map(str, ans))
if ans[-1] == 0:
for i in range(len(ans)):
if ans[-1 - i] != 0:
ans[-1 - i] -= 1
break
ans[-1] = 1
ans2 = "".join(map(str, ans[::-1]))
print(ans2, ans1)
elif flag == 0 and s == 0 and m == 1:
print(0, 0)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER WHILE VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER 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 | line = input()
temp = line.split()
m = int(temp[0])
s = int(temp[1])
if s == 0:
if m != 1:
print("-1 -1")
else:
print("0 0")
elif 9 * m < s:
print("-1 -1")
elif m == 1:
print(s, end=" ")
print(s)
else:
s1 = s
a = [(0) for i in range(m)]
b = [(0) for i in range(m)]
i = m
while s > 9:
i -= 1
a[i] = 9
s -= 9
if i == 1:
a[0] = s
elif i >= 2:
a[0] = 1
a[i - 1] = s - 1
i = -1
s = s1
while s > 9:
i += 1
b[i] = 9
s -= 9
if i == m - 2:
b[m - 1] = s
elif i < m - 2:
b[i + 1] = s
for i in range(m - 1):
print(a[i], end="")
print(a[m - 1], end=" ")
for i in range(m):
print(b[i], end="") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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 | def solve(m, s):
min_num, max_num = list(), list()
tot = s
for i in range(m):
min_num.append(0)
max_num.append(0)
itr = 0
while itr < m:
max_num[itr] = min(9, tot)
tot -= min(tot, 9)
itr += 1
itr, tot = 0, s
min_num[m - 1] = 1
tot -= 1
while tot > 0 and itr < m:
if min_num[itr] < 9:
min_num[itr] += 1
tot -= 1
else:
itr += 1
min_num[itr] += 1
tot -= 1
new_min, new_max = "", ""
for i in range(m):
new_min += str(min_num[m - i - 1])
new_max += str(max_num[i])
return new_min, new_max
m, s = map(int, input().split())
if m * 9 >= s:
if s > 0:
new_min, new_max = solve(m, s)
print(new_min, new_max)
if s == 0:
if m == 1:
print(0, 0)
else:
print(-1, -1)
else:
print(-1, -1) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER 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 | def min_len_sum(m, s):
a = [[]] * (m + 1)
for i in range(m + 1):
a[i] = ["-1"] * (s + 1)
for j in range(min(s, 9) + 1):
a[1][j] = str(j)
for i in range(2, m + 1):
a1 = a[i - 1]
a0 = a[i]
for j1 in range(1, s + 1):
if a1[j1] == "-1":
break
for d in range(10):
j = j1 + d
if j > s:
break
new_val = a1[j1] + str(d)
if a0[j] == "-1" or new_val < a0[j]:
a0[j] = new_val
return a[m][s]
def max_len_sum(m, s):
a = [[]] * (m + 1)
for i in range(m + 1):
a[i] = ["-1"] * (s + 1)
for j in range(min(s, 9) + 1):
a[1][j] = str(j)
for i in range(2, m + 1):
a1 = a[i - 1]
a0 = a[i]
for j1 in range(1, s + 1):
if a1[j1] == "-1":
break
for d in range(10):
j = j1 + d
if j > s:
break
new_val = a1[j1] + str(d)
if a0[j] == "-1" or new_val > a0[j]:
a0[j] = new_val
return a[m][s]
def main():
m, s = map(int, input().split())
print(min_len_sum(m, s), max_len_sum(m, s))
main() | FUNC_DEF ASSIGN VAR BIN_OP LIST LIST BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST LIST BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF 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 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(" "))
def greatest(m, s):
if m == 0:
return ""
dig = min(s, 9)
return str(dig) + greatest(m - 1, s - dig)
def smallest(m, s):
dig = max(1, 9 - 9 * m + s)
return str(dig) + greatest(m - 1, s - 1)[::-1]
if 9 * m < s:
print("-1 -1")
quit()
if s == 0:
if m != 1:
print("-1 -1")
else:
print("0 0")
quit()
print(smallest(m, s), " ", greatest(m, s)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR 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, list(input().split()))
if s != 0:
if s < 9 * m:
b = s // 9
c = s % 9
if b == m - 1:
n1 = str(c) + b * "9"
n2 = b * "9" + str(c)
else:
if c != 0:
n1 = "1" + (m - 1 - b - 1) * "0" + str(c - 1) + b * "9"
else:
n1 = "1" + (m - 1 - b - 1) * "0" + str(c) + "8" + (b - 1) * "9"
n2 = b * "9" + str(c) + (m - 1 - b) * "0"
elif s == 9 * m:
n1 = m * "9"
n2 = m * "9"
else:
n1 = "-1"
n2 = "-1"
print(n1, end=" ")
print(n2)
elif m == 1:
print("0 0")
else:
print("-1 -1") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER STRING FUNC_CALL VAR VAR STRING BIN_OP BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR STRING FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR STRING IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR IF 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()]
minn = maxn = ""
smin = smax = s
def possible(sum, digits):
return sum >= 0 and sum <= 9 * digits
for i in range(m):
for j in range(10):
if possible(smin - j, m - i - 1) and (i > 0 or j > 0 or m == 1 and j == 0):
minn += str(j)
smin -= j
break
else:
print(-1, -1)
exit()
for i in range(m):
for j in range(9, -1, -1):
if possible(smax - j, m - i - 1) and (i > 0 or j > 0 or m == 1 and j == 0):
maxn += str(j)
smax -= j
break
if int(minn) == 0 and m != 1:
print(-1, -1)
else:
print(minn, maxn) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING ASSIGN VAR VAR VAR FUNC_DEF RETURN VAR NUMBER VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL 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 | n, s = list(map(int, input().split()))
if s != 0:
if n * 9 >= s:
Max = "9" * (s // 9)
if s % 9 != 0:
Max += str(s % 9)
if len(Max) < n:
Max += "0" * (n - len(Max))
Min = list(map(int, Max))
Min.sort()
if Min[0] == 0:
for n in range(1, len(Min)):
if Min[n] >= 1:
Min[0] += 1
Min[n] -= 1
break
X = []
for val in Min:
X.append(str(val))
X = "".join(X)
print(X, Max)
else:
print(-1, -1)
elif n == 1:
print(0, 0)
else:
print(-1, -1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF 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 | line = input().split()
n = int(line[0])
t = int(line[1])
a = ""
if t > 9 * n or n > 1 and t == 0:
print("-1 -1")
elif n == 1 and t == 0:
print("0 0")
else:
m = int(t / 9)
b = t % 9
if b != 0:
maxa = "9" * m + str(b)
for i in range(n - len(maxa)):
maxa += "0"
else:
maxa = "9" * m
for i in range(n - len(maxa)):
maxa += "0"
if b != 0:
mina = str(b) + "9" * m
for i in range(n - len(mina)):
a += "0"
mina = a + mina
if mina.count("0") > 0:
mina = list(mina)
for y in range(len(mina)):
mina[y] = int(mina[y])
mina[mina.count(0)] = mina[mina.count(0)] - 1
mina[0] = 1
else:
mina = "9" * m
for i in range(n - len(mina)):
a += "0"
mina = a + mina
if mina.count("0") > 0:
mina = list(mina)
for y in range(len(mina)):
mina[y] = int(mina[y])
mina[mina.count(0)] = mina[mina.count(0)] - 1
mina[0] = 1
mina = list(mina)
for y in range(len(mina)):
mina[y] = int(mina[y])
for y in range(len(mina)):
mina[y] = str(mina[y])
print("".join(mina), maxa) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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_smallest(m, s):
n = []
for i in range(m):
if 9 < s:
n.append(9)
s -= 9
else:
n.append(s - 1)
s -= s - 1
n[-1] += 1
return "".join(str(i) for i in n[::-1])
def get_biggest(m, s):
n = []
for i in range(m):
n.append(min(9, s))
s -= n[-1]
return "".join(str(i) for i in n)
m, s = map(int, input().split())
if m * 9 < s or s == 0 and 1 < m:
print("-1 -1")
else:
print(get_smallest(m, s) + " " + get_biggest(m, s)) | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR 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] = list(map(int, input().split()))
if s == 0 and m > 1 or s > m * 9:
print(-1, -1)
elif m == 1:
print(s, s)
else:
ma = ""
for i in range(s // 9):
ma = ma + "9"
if s % 9 != 0:
ma = ma + str(s % 9)
for i in range(m - len(ma)):
ma += "0"
mi = ""
for i in range((s - 1) // 9):
mi = "9" + mi
if (s - 1) % 9 != 0:
mi = str((s - 1) % 9) + mi
for i in range(m - len(mi)):
mi = "0" + mi
mi = str(int(mi[0]) + 1) + mi[1:]
print(mi, ma) | ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 | n, s = map(int, input().split())
if n == 1 and s == 0:
print(0, 0)
exit(0)
if s > 9 * n or s == 0:
print(-1, -1)
exit(0)
a = [0] * n
a[0] = 1
ss = 1
ind = n - 1
while ind >= 0:
if s - ss > 9:
ss += 9
a[ind] = 9
else:
if ind == 0:
a[ind] = s - ss + 1
else:
a[ind] = s - ss
break
ind -= 1
s1 = str.join("", map(str, a))
a = [0] * n
ss = 0
ind = 0
while ind < n:
if s - ss > 9:
ss += 9
a[ind] = 9
else:
a[ind] = s - ss
break
ind += 1
print(s1 + " " + str.join("", map(str, a))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING FUNC_CALL VAR 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())
max_ = 9 * m
if s == 0 and m > 1 or s > max_:
print(-1, -1)
else:
m2 = m
s2 = s
digits = [1] + [0] * (m - 1)
if s == 0:
digits[0] = 0
else:
s -= 1
m -= 1
while s > 0:
if m == 0:
s += 1
digits[m] = min(9, s)
s -= digits[m]
m -= 1
digits2 = [0] * m2
i = 0
while s2 > 0:
digits2[i] = min(9, s2)
s2 -= digits2[i]
i += 1
print("".join(map(str, digits)), "".join(map(str, digits2))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR 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 | n = input().split()
a = int(n[0])
b = int(n[1])
c = b
if a > 1 and b < 1 or b > a * 9:
print("-1 -1")
else:
t = 10 ** (a - 1)
b = b - 1
k = 0
w = 0
while b >= 9:
k = 9 + 10 * k
b = b - 9
w = w + 1
k = b * 10**w + k
q = t + k
if c < 9:
p = c * 10 ** (a - 1)
elif c == a * 9:
p = "9" * a
else:
p = ""
while c >= 9:
p = "9" + p
a = a - 1
c = c - 9
p = p + str(c)
if c == 0:
p = p[0 : a + 1]
for i in range(0, a - 1):
p = p + "0"
print(q)
print(p) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.