結果

問題 No.1339 循環小数
ユーザー 👑 H20H20
提出日時 2021-01-15 22:54:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 64,256 KB
最終ジャッジ日時 2024-05-05 00:54:23
合計ジャッジ時間 5,497 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
57,600 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
#素因数分解
#collections.Counter(prime_factorize(N))で個数を取得

#最大公約数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

T = int(input())
for i in range(T):
    N = int(input())
    L=list(set(prime_factorize(N)))
    if 2 in L:
        L.remove(2)
    if 5 in L:
        L.remove(5)
    if len(L)==0:
        print(1)
    else:
        rep = []
        for l in L:
            temp = 9 % l
            cnt = 1
            while temp!=0:
                temp = (temp*10+9)%l
                cnt+=1
            rep.append(cnt)
        lc = 1
        for r in rep:
            lc = lcm(lc,r)
        print(lc)
0