QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#262654 | #885. Keep Calm And Carry Off | Fyind# | RE | 10ms | 8192kb | Python3 | 925b | 2023-11-23 21:16:32 | 2023-11-23 21:16:32 |
Judging History
answer
x = int(input())
y = int(input())
sum = x + y
sumstr = str(sum)[::-1]
sumlen = sumstr.__len__()
xstr = str(x)[::-1]
xstr = xstr.ljust(sumlen, "0")
ystr = str(y)[::-1]
ystr = ystr.ljust(sumlen, "0")
pos = -1
for i in range(sumlen):
if (int(xstr[i]) + int(ystr[i]) != int(sumstr[i])):
pos = i
# print(xstr[i], ystr[i], sumstr[i])
if pos == -1:
print(0)
else:
ans = min(x, y)
ansxstr = ("0" * pos) + str(int(xstr[pos]) + 1)
if pos < sumlen:
ansxstr += xstr[pos + 1:]
# ansxstr = ansxstr[:str(x).__len__()]
# print(ansxstr)
revx = int(ansxstr[::-1])
ans = min(ans, abs(x - revx))
ansystr = ("0" * pos) + str(int(ystr[pos]) + 1)
if pos < sumlen:
ansystr += ystr[pos + 1:]
# ansystr = ansystr[:str(y).__len__()]
# print(ansystr)
revy = int(ansystr[::-1])
ans = min(ans, abs(y - revy))
print(ans)
详细
Test #1:
score: 100
Accepted
time: 5ms
memory: 8056kb
input:
10 99
output:
1
result:
ok answer is '1'
Test #2:
score: 0
Accepted
time: 9ms
memory: 8156kb
input:
90 10
output:
10
result:
ok answer is '10'
Test #3:
score: 0
Accepted
time: 5ms
memory: 8192kb
input:
23425 487915
output:
12085
result:
ok answer is '12085'
Test #4:
score: 0
Accepted
time: 9ms
memory: 8124kb
input:
1 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 7ms
memory: 8140kb
input:
99 99
output:
1
result:
ok answer is '1'
Test #6:
score: 0
Accepted
time: 9ms
memory: 8164kb
input:
14 86
output:
14
result:
ok answer is '14'
Test #7:
score: 0
Accepted
time: 10ms
memory: 8164kb
input:
899999999999999999999 100000000000000000001
output:
100000000000000000001
result:
ok answer is '100000000000000000001'
Test #8:
score: -100
Dangerous Syscalls
input:
615357649595284099508435993883986571313695656691562389866620971630644953030429613681442060702023197532680463771166724257258948140032009435767225187778914625685600736964207275868974321513156027752788270804733647164380664571327109020774746630643814103150883559720458844636326901760106285413007100737536...