QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#262751 | #885. Keep Calm And Carry Off | Fyind | WA | 10ms | 8160kb | Python3 | 1018b | 2023-11-23 22:54:34 | 2023-11-23 22:54:35 |
Judging History
answer
import sys
sys.setrecursionlimit(10000000)
def toInt (x):
ret=0
l=reversed(range (len(x)))
for i in l:
ret=ret*10+int (x[i])
return ret
x = toInt(input())
y = toInt(input())
ss = x + y
sumstr = str(ss)[::-1]
sumlen = len(sumstr)
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) + xstr[pos + 1:]
# ansxstr = ansxstr[:str(x).__len__()]
# print(ansxstr)
revx = toInt(ansxstr[::-1])
ans = min(ans, abs(x - revx))
ansystr = ("0" * pos) + str(int(ystr[pos]) + 1) + ystr[pos + 1:]
# ansystr = ansystr[:str(y).__len__()]
# print(ansystr)
revy = toInt(ansystr[::-1])
ans = min(ans, abs(y - revy))
print(ans)
詳細信息
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 8160kb
input:
10 99
output:
0
result:
wrong answer expected '1', found '0'