Submission #3750479


Source Code Expand

n = int(input())

while n % 2 == 0:
    n //= 2
while n % 5 == 0:
    n //= 5
if n == 1:
    print(1)
else:
    X = [n for i in range(n)]
    
    j = 1
    s = 1
    post = []
    m = 0
    while True:
        s *= 10
        s %= n
        post.append(s)
        X[s] = min(j, X[s])
        m += 1
        if s == 1:
            break
    ans = 0
    while True:
        if ans > 0:
            break
        pre = post
        post = []
        j += 1
        for p in pre:
            pp = (p + 1) % n
            if pp == 0:
                X[0] = j
                ans = j
                break
            if X[pp] == n:
                for i in range(m):
                    post.append(pp)
                    X[pp] = j
                    pp *= 10
                    pp %= n
    print(ans)

Submission Info

Submission Time
Task D - Small Multiple
User Kiri8128
Language Python (3.4.3)
Score 700
Code Size 842 Byte
Status AC
Exec Time 146 ms
Memory 12944 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 67
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 18 ms 3064 KB
02.txt AC 18 ms 3064 KB
03.txt AC 18 ms 3064 KB
04.txt AC 18 ms 3064 KB
05.txt AC 18 ms 3064 KB
06.txt AC 18 ms 3064 KB
07.txt AC 18 ms 3064 KB
08.txt AC 18 ms 3064 KB
09.txt AC 18 ms 3064 KB
10.txt AC 18 ms 3064 KB
11.txt AC 18 ms 3064 KB
12.txt AC 18 ms 3064 KB
13.txt AC 18 ms 3064 KB
14.txt AC 18 ms 3064 KB
15.txt AC 18 ms 3064 KB
16.txt AC 18 ms 3064 KB
17.txt AC 18 ms 3064 KB
18.txt AC 18 ms 3064 KB
19.txt AC 18 ms 3064 KB
20.txt AC 18 ms 3064 KB
21.txt AC 18 ms 3064 KB
22.txt AC 90 ms 4244 KB
23.txt AC 46 ms 5392 KB
24.txt AC 146 ms 12944 KB
25.txt AC 35 ms 4084 KB
26.txt AC 32 ms 3956 KB
27.txt AC 99 ms 9500 KB
28.txt AC 69 ms 6940 KB
29.txt AC 33 ms 3956 KB
30.txt AC 90 ms 7832 KB
31.txt AC 18 ms 3064 KB
32.txt AC 18 ms 3064 KB
33.txt AC 77 ms 6552 KB
34.txt AC 37 ms 4468 KB
35.txt AC 55 ms 6356 KB
36.txt AC 22 ms 3188 KB
37.txt AC 34 ms 4080 KB
38.txt AC 29 ms 3864 KB
39.txt AC 48 ms 4888 KB
40.txt AC 20 ms 3064 KB
41.txt AC 43 ms 4888 KB
42.txt AC 92 ms 6568 KB
43.txt AC 26 ms 3444 KB
44.txt AC 20 ms 3188 KB
45.txt AC 34 ms 3828 KB
46.txt AC 74 ms 5780 KB
47.txt AC 23 ms 3064 KB
48.txt AC 45 ms 3572 KB
49.txt AC 36 ms 3700 KB
50.txt AC 38 ms 3828 KB
51.txt AC 32 ms 3700 KB
52.txt AC 32 ms 3700 KB
53.txt AC 48 ms 4120 KB
54.txt AC 32 ms 3444 KB
55.txt AC 54 ms 4504 KB
56.txt AC 28 ms 3316 KB
57.txt AC 115 ms 6388 KB
58.txt AC 70 ms 4120 KB
59.txt AC 77 ms 4504 KB
60.txt AC 65 ms 3992 KB
61.txt AC 19 ms 3064 KB
62.txt AC 26 ms 3064 KB
63.txt AC 25 ms 3188 KB
64.txt AC 87 ms 4244 KB
s1.txt AC 18 ms 3064 KB
s2.txt AC 18 ms 3064 KB
s3.txt AC 25 ms 3188 KB