UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213368#2355. Digitwangyaxu1230274ms12108kbPython3699b2024-11-11 20:27:522024-11-11 23:04:02

answer

def a(n):
    queue = [(0, 0)]  # 用队列存储 (当前值, 加1操作次数) 的元组,初始为 (0, 0)
    visited = set()  # 用于记录已经访问过的数值,避免重复计算

    while queue:
        current_value, add_ones_count = queue.pop(0)

        if current_value % n == 0 and current_value > 0:
            return add_ones_count

        if current_value not in visited:
            visited.add(current_value)

            # 进行乘以10的操作
            queue.append((current_value * 10, add_ones_count))

            # 进行加1的操作
            queue.append((current_value + 1, add_ones_count + 1))
n=int(input())
result = a(n)
print(result)

详细

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

Test #1:

score: 0
Wrong Answer
time: 37ms
memory: 7084kb

input:

81920

output:

7

result:

wrong answer 1st numbers differ - expected: '1', found: '7'

Test #2:

score: 0
Time Limit Exceeded

input:

55966

output:


result:


Test #3:

score: 0
Time Limit Exceeded

input:

92661

output:


result:


Test #4:

score: 0
Time Limit Exceeded

input:

68013

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

72927

output:


result:


Test #6:

score: 0
Wrong Answer
time: 237ms
memory: 12108kb

input:

15047

output:

9

result:

wrong answer 1st numbers differ - expected: '5', found: '9'

Test #7:

score: 0
Time Limit Exceeded

input:

59994

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

97273

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

51139

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

55788

output:


result: