QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607338 | #8932. Bingo | UESTC_NLNS# | WA | 17ms | 10572kb | Python3 | 1.2kb | 2024-10-03 14:45:13 | 2024-10-03 14:45:14 |
Judging History
answer
import sys
sys.set_int_max_str_digits(10**6 + 5)
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
a1 = str(a1)
n += 1
n1 = str(n)
if m1 in n1:
print(n1)
continue
lm = len(m1)
n21 = n1[: -2 * lm + 1]
n2 = n1[-2 * lm + 1 :]
a2 = "9" * len(n2)
for i in range(0, len(n2) - lm + 1):
ok = 1
for j in range(0, len(n2) - i - lm):
if n2[i + j] != m1[j]:
ok = 0
break
j = len(n2) - i - lm
# print(f"{j, ok}")
if ok == 0 or (i != len(n2) - lm and m1[j] <= n2[i + j]):
continue
a3 = m1[-i - 1 :] + "0" * (len(n2) - lm - i)
# print(f"{m1 = },{a3 = }")
# a3 = n2[:i] + m1 + "0" * (len(n2) - lm - i)
# if a3 >= n2:
# a2 = min(a2, a3)
a2 = n21 + str(a2)
if len(a1) < len(a2):
print(a1)
elif len(a2) < len(a1):
print(a2)
else:
print(min(a1, a2))
"""
6
7 3
12 3
9 10
249 51
1369 37
2 1
1
100000000001244 453
1
249 51
"""
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 17ms
memory: 10572kb
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1
output:
9 13 10 255 1370 3
result:
wrong answer 4th lines differ - expected: '251', found: '255'