結果

問題 No.1339 循環小数
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-01-15 22:02:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 76,064 KB
最終ジャッジ日時 2023-08-17 17:09:13
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
70,968 KB
testcase_01 AC 84 ms
75,304 KB
testcase_02 AC 83 ms
74,900 KB
testcase_03 AC 82 ms
75,372 KB
testcase_04 AC 82 ms
75,276 KB
testcase_05 AC 83 ms
75,080 KB
testcase_06 AC 83 ms
75,076 KB
testcase_07 AC 81 ms
75,004 KB
testcase_08 AC 83 ms
75,516 KB
testcase_09 AC 86 ms
75,688 KB
testcase_10 AC 85 ms
75,308 KB
testcase_11 AC 90 ms
75,988 KB
testcase_12 AC 90 ms
75,812 KB
testcase_13 AC 89 ms
75,660 KB
testcase_14 AC 86 ms
75,816 KB
testcase_15 AC 88 ms
75,712 KB
testcase_16 AC 88 ms
75,828 KB
testcase_17 AC 84 ms
76,004 KB
testcase_18 AC 88 ms
76,028 KB
testcase_19 AC 88 ms
75,840 KB
testcase_20 AC 86 ms
75,856 KB
testcase_21 AC 130 ms
76,064 KB
testcase_22 AC 128 ms
75,636 KB
testcase_23 AC 132 ms
75,664 KB
testcase_24 AC 125 ms
76,020 KB
testcase_25 AC 132 ms
75,756 KB
testcase_26 AC 129 ms
75,812 KB
testcase_27 AC 127 ms
75,756 KB
testcase_28 AC 128 ms
75,976 KB
testcase_29 AC 119 ms
75,820 KB
testcase_30 AC 124 ms
75,756 KB
testcase_31 AC 187 ms
75,892 KB
testcase_32 AC 191 ms
75,828 KB
testcase_33 AC 129 ms
75,784 KB
testcase_34 AC 100 ms
75,828 KB
testcase_35 AC 180 ms
76,056 KB
testcase_36 AC 126 ms
75,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    if n == 1:
        return [1]
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def f(x):
    p = n = x
    d = 2
    while d * d <= n:
        if n % d == 0:
            p = p * (d - 1) // d
            while n % d == 0:
                n //= d
        d += 1
    return [p, p * (n - 1) // n][n > 1]

for _ in range(int(input())):
    n = int(input())
    while n % 2 == 0:
        n //= 2
    while n % 5 == 0:
        n //= 5
    if n == 1:
        print(1)
        continue
    euler = f(n)
    divs = make_divisors(euler)
    for i in divs:
        if pow(10, i, n) == 1:
            print(i)
            break
0