QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#262739#885. Keep Calm And Carry OffFyindRE 10ms8196kbPython3890b2023-11-23 22:38:212023-11-23 22:38:22

Judging History

你现在查看的是最新测评结果

  • [2023-11-23 22:38:22]
  • 评测
  • 测评结果:RE
  • 用时:10ms
  • 内存:8196kb
  • [2023-11-23 22:38:21]
  • 提交

answer

import sys
sys.setrecursionlimit(10000000)

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) + 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) + 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: 8156kb

input:

10
99

output:

1

result:

ok answer is '1'

Test #2:

score: 0
Accepted
time: 6ms
memory: 8096kb

input:

90
10

output:

10

result:

ok answer is '10'

Test #3:

score: 0
Accepted
time: 10ms
memory: 8124kb

input:

23425
487915

output:

12085

result:

ok answer is '12085'

Test #4:

score: 0
Accepted
time: 6ms
memory: 8196kb

input:

1
1

output:

0

result:

ok answer is '0'

Test #5:

score: 0
Accepted
time: 7ms
memory: 8164kb

input:

99
99

output:

1

result:

ok answer is '1'

Test #6:

score: 0
Accepted
time: 10ms
memory: 8184kb

input:

14
86

output:

14

result:

ok answer is '14'

Test #7:

score: 0
Accepted
time: 4ms
memory: 8124kb

input:

899999999999999999999
100000000000000000001

output:

100000000000000000001

result:

ok answer is '100000000000000000001'

Test #8:

score: -100
Dangerous Syscalls

input:

615357649595284099508435993883986571313695656691562389866620971630644953030429613681442060702023197532680463771166724257258948140032009435767225187778914625685600736964207275868974321513156027752788270804733647164380664571327109020774746630643814103150883559720458844636326901760106285413007100737536...

output:


result: