結果

問題 No.1339 循環小数
ユーザー Kiri8128Kiri8128
提出日時 2020-11-23 01:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2023-10-11 02:16:25
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,692 KB
testcase_01 AC 81 ms
76,964 KB
testcase_02 AC 83 ms
76,568 KB
testcase_03 AC 81 ms
76,484 KB
testcase_04 AC 81 ms
76,500 KB
testcase_05 AC 81 ms
76,884 KB
testcase_06 AC 80 ms
76,184 KB
testcase_07 AC 81 ms
76,588 KB
testcase_08 AC 83 ms
76,800 KB
testcase_09 AC 83 ms
76,700 KB
testcase_10 AC 80 ms
76,620 KB
testcase_11 AC 86 ms
76,940 KB
testcase_12 AC 86 ms
76,680 KB
testcase_13 AC 87 ms
76,800 KB
testcase_14 AC 84 ms
77,052 KB
testcase_15 AC 87 ms
76,800 KB
testcase_16 AC 88 ms
76,988 KB
testcase_17 AC 86 ms
76,768 KB
testcase_18 AC 84 ms
77,180 KB
testcase_19 AC 84 ms
76,592 KB
testcase_20 AC 85 ms
76,872 KB
testcase_21 AC 101 ms
77,128 KB
testcase_22 AC 100 ms
76,960 KB
testcase_23 AC 99 ms
77,184 KB
testcase_24 AC 101 ms
77,044 KB
testcase_25 AC 99 ms
77,268 KB
testcase_26 AC 95 ms
77,028 KB
testcase_27 AC 97 ms
77,044 KB
testcase_28 AC 95 ms
77,312 KB
testcase_29 AC 99 ms
77,208 KB
testcase_30 AC 96 ms
77,040 KB
testcase_31 AC 110 ms
77,048 KB
testcase_32 AC 112 ms
77,256 KB
testcase_33 AC 101 ms
77,172 KB
testcase_34 AC 84 ms
76,920 KB
testcase_35 AC 106 ms
76,680 KB
testcase_36 AC 97 ms
77,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret
def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)
def calc(n):
    while n % 2 == 0:
        n //= 2
    while n % 5 == 0:
        n //= 5
    if n == 1:
        return 1
    pf = primeFactor(n)
    a = 1
    for p in pf:
        a *= (p - 1) * p ** (pf[p] - 1)
    
    for d in divisors(a):
        if pow(10, d, n) == 1:
            return d
            break
T = int(input())
for _ in range(T):
    N = int(input())
    print(calc(N))
0