結果

問題 No.1339 循環小数
ユーザー ayaoniayaoni
提出日時 2021-01-16 01:55:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,944 KB
最終ジャッジ日時 2023-08-17 20:17:30
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,884 KB
testcase_01 AC 82 ms
75,788 KB
testcase_02 AC 81 ms
75,720 KB
testcase_03 AC 82 ms
75,716 KB
testcase_04 AC 79 ms
76,112 KB
testcase_05 AC 78 ms
75,680 KB
testcase_06 AC 80 ms
75,768 KB
testcase_07 AC 82 ms
76,108 KB
testcase_08 AC 81 ms
75,996 KB
testcase_09 AC 82 ms
75,836 KB
testcase_10 AC 78 ms
76,080 KB
testcase_11 AC 86 ms
76,288 KB
testcase_12 AC 85 ms
76,656 KB
testcase_13 AC 86 ms
76,624 KB
testcase_14 AC 82 ms
76,548 KB
testcase_15 AC 84 ms
76,768 KB
testcase_16 AC 85 ms
76,500 KB
testcase_17 AC 86 ms
76,656 KB
testcase_18 AC 86 ms
76,700 KB
testcase_19 AC 84 ms
76,588 KB
testcase_20 AC 84 ms
76,652 KB
testcase_21 AC 135 ms
76,608 KB
testcase_22 AC 144 ms
76,576 KB
testcase_23 AC 140 ms
76,336 KB
testcase_24 AC 140 ms
76,656 KB
testcase_25 AC 140 ms
76,944 KB
testcase_26 AC 141 ms
76,360 KB
testcase_27 AC 141 ms
76,288 KB
testcase_28 AC 138 ms
76,504 KB
testcase_29 AC 131 ms
76,620 KB
testcase_30 AC 134 ms
76,656 KB
testcase_31 AC 180 ms
76,660 KB
testcase_32 AC 180 ms
76,524 KB
testcase_33 AC 145 ms
76,656 KB
testcase_34 AC 100 ms
76,700 KB
testcase_35 AC 170 ms
76,936 KB
testcase_36 AC 139 ms
76,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


def phi(n):
    ans = n
    for i in range(2,int(n**.5)+1):
        if n % i == 0:
            ans = (ans*(i-1))//i
            while n % i == 0:
                n //= i
            if n == 1:  # 時間短縮
                break
    if n != 1:
        ans = (ans*(n-1))//n
    return ans


def divisor(n):  # nの約数全列挙
    res = []
    for i in range(1,int(n**.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n//i:
                res.append(n//i)
    return res


T = I()
for _ in range(T):
    N = I()
    while N % 2 == 0:
        N //= 2
    while N % 5 == 0:
        N //= 5

    if N == 1:
        print(1)
        continue

    r = phi(N)
    div = divisor(r)
    div.sort()

    for d in div:
        if pow(10,d,N) == 1:
            print(d)
            break
0