UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213417#2355. Digitjsxheng1001202ms9204kbPython3638b2024-11-11 21:48:412024-11-11 23:08:51

answer

def A(dist, start, startValue, traverse):
    from heapq import heappop, heappush
    dist[start] = startValue
    queue = [(startValue, start)]
    while queue:
        value, node = heappop(queue)
        if dist[node] == value:
            for node2, value2 in traverse(node, value):
                if dist[node2] > value2:
                    dist[node2] = value2
                    heappush(queue, (value2, node2))
    return dist
def B(n):
    def traverse(remainder, add1):
        return [((remainder*10)%n, add1), ((remainder+1)%n, add1+1)]
    return A([n+1]*n, 1%n, 1, traverse)[0]
n=int(input())
print(B(n))

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 138ms
memory: 6740kb

input:

81920

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 10
Accepted
time: 115ms
memory: 8616kb

input:

55966

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 10
Accepted
time: 182ms
memory: 9204kb

input:

92661

output:

3

result:

ok 1 number(s): "3"

Test #4:

score: 10
Accepted
time: 121ms
memory: 6312kb

input:

68013

output:

18

result:

ok 1 number(s): "18"

Test #5:

score: 10
Accepted
time: 125ms
memory: 6352kb

input:

72927

output:

27

result:

ok 1 number(s): "27"

Test #6:

score: 10
Accepted
time: 35ms
memory: 5852kb

input:

15047

output:

5

result:

ok 1 number(s): "5"

Test #7:

score: 10
Accepted
time: 97ms
memory: 5948kb

input:

59994

output:

36

result:

ok 1 number(s): "36"

Test #8:

score: 10
Accepted
time: 179ms
memory: 8212kb

input:

97273

output:

10

result:

ok 1 number(s): "10"

Test #9:

score: 10
Accepted
time: 110ms
memory: 6476kb

input:

51139

output:

14

result:

ok 1 number(s): "14"

Test #10:

score: 10
Accepted
time: 100ms
memory: 6736kb

input:

55788

output:

15

result:

ok 1 number(s): "15"

Extra Test:

score: 0
Extra Test Passed