UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213371#2355. DigitWZRYWZWY1001492ms9200kbPython3737b2024-11-11 20:32:212024-11-11 23:04:17

answer

def dijkstra(dist, start, startValue, traverse):  # Dijkstra's algorithm
    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 A077196(n):
    def traverse(remainder, add1):
        return [((remainder*10)%n, add1), ((remainder+1)%n, add1+1)]
    return dijkstra([n+1]*n, 1%n, 1, traverse)[0]

n = int(input())
print(A077196(n))

# 我有一计,oeis————WZRYWZWY

详细

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

Test #1:

score: 10
Accepted
time: 132ms
memory: 6744kb

input:

81920

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

55966

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 10
Accepted
time: 177ms
memory: 9200kb

input:

92661

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

68013

output:

18

result:

ok 1 number(s): "18"

Test #5:

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

input:

72927

output:

27

result:

ok 1 number(s): "27"

Test #6:

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

input:

15047

output:

5

result:

ok 1 number(s): "5"

Test #7:

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

input:

59994

output:

36

result:

ok 1 number(s): "36"

Test #8:

score: 10
Accepted
time: 318ms
memory: 8204kb

input:

97273

output:

10

result:

ok 1 number(s): "10"

Test #9:

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

input:

51139

output:

14

result:

ok 1 number(s): "14"

Test #10:

score: 10
Accepted
time: 190ms
memory: 6492kb

input:

55788

output:

15

result:

ok 1 number(s): "15"

Extra Test:

score: 0
Extra Test Passed