QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620162 | #8932. Bingo | zzpcd# | WA | 7ms | 10652kb | Python3 | 1.2kb | 2024-10-07 16:51:25 | 2024-10-07 16:51:35 |
Judging History
answer
import sys
sys.set_int_max_str_digits(2000105)
def myint(x : str):
if len(x) == 0:
return int(0)
return int(x)
T = int(input())
for _ in range(T):
n, m = input().split()
N = int(n)
n = n
M = int(m)
N += 1
n = str(N)
if N <= M :
print(M)
continue
if n.find(m) != -1:
print(N)
continue
Ans = (N + M - 1) // M * M
orgN = N
N += M
n = str(N)
g = n.find(m)
if g != -1 and g + len(m) + len(m) <= len(n):
Ans = min(Ans, N - myint(n[-len(m):]))
ri = M
rt = 1
now = int(0)
for i in range(11):
tmp = myint(n[-(len(m)+i):])
if tmp <= M * rt:
ri = min(ri, M * rt - tmp)
rt *= 10
# if now < ri:
# if(len(n) >= i + 1):
# ch = int(n[-i-1])
# else:
# ch = 0
# if ch==0:
# continue
# now += (10 - ch) * 10**i
# if now < ri:
# N += (10 - ch) * 10**i
# n = str(N)
# if n.find(m) != -1:
# ri = min(ri, now)
# print(ri)
Ans = min(Ans, orgN + ri)
print(Ans)
详细
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 10652kb
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'