UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213378#2355. Digitlina1001271ms9204kbPython3536b2024-11-11 21:01:372024-11-11 23:05:00

answer

def dijkstra(dist, s, val, t):
    from heapq import heappop, heappush
    dist[s] = val
    queue = [(val, s)]
    while queue:
        val, node = heappop(queue)
        if dist[node] == val:
            for u, w in t(node, val):
                if dist[u] > w:
                    dist[u] = w
                    heappush(queue, (w, u))
    return dist
def solve(n):
    def t(re, add1):
        return [((re*10)%n, add1), ((re+1)%n, add1+1)]
    return dijkstra([n+1]*n, 1%n, 1, t)[0]
n=int(input())
print(solve(n))

详细

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

Test #1:

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

input:

81920

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 10
Accepted
time: 118ms
memory: 8608kb

input:

55966

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

92661

output:

3

result:

ok 1 number(s): "3"

Test #4:

score: 10
Accepted
time: 118ms
memory: 6300kb

input:

68013

output:

18

result:

ok 1 number(s): "18"

Test #5:

score: 10
Accepted
time: 135ms
memory: 6340kb

input:

72927

output:

27

result:

ok 1 number(s): "27"

Test #6:

score: 10
Accepted
time: 39ms
memory: 5848kb

input:

15047

output:

5

result:

ok 1 number(s): "5"

Test #7:

score: 10
Accepted
time: 106ms
memory: 5952kb

input:

59994

output:

36

result:

ok 1 number(s): "36"

Test #8:

score: 10
Accepted
time: 199ms
memory: 8200kb

input:

97273

output:

10

result:

ok 1 number(s): "10"

Test #9:

score: 10
Accepted
time: 111ms
memory: 6484kb

input:

51139

output:

14

result:

ok 1 number(s): "14"

Test #10:

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

input:

55788

output:

15

result:

ok 1 number(s): "15"

Extra Test:

score: 0
Extra Test Passed