QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607025 | #8932. Bingo | UESTC_NLNS# | TL | 0ms | 0kb | Python3 | 685b | 2024-10-03 13:40:30 | 2024-10-03 13:40:31 |
answer
import sys
sys.maxsize = 10 ** (10**7)
t = int(input())
for i in range(t):
n1, m1 = input().split()
n, m = map(int, [n1, m1])
if n < m:
print(m)
continue
a1 = (n // m + 1) * m
n += 1
n1 = str(n)
if m1 in n1:
print(n1)
continue
lm = len(m1)
n21 = n1[: -2 * lm - 3]
n2 = n1[-2 * lm - 3 :]
n2i = int(n2)
# print(n2)
a2 = "9" * len(n2)
for i in range(0, len(n2) - lm + 1):
a3 = n2[:i] + m1 + "0" * (len(n2) - lm - i)
# print(a3)
if a3 >= n2:
a2 = min(a2, a3)
# print(a1, a2)
a2 = int(n21 + str(a2))
print(min(a1, a2))
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1