結果

問題 No.1339 循環小数
ユーザー 👑 H20H20
提出日時 2021-01-16 00:07:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 847 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 65,408 KB
最終ジャッジ日時 2024-05-05 02:12:48
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,136 KB
testcase_01 AC 48 ms
59,776 KB
testcase_02 AC 48 ms
60,032 KB
testcase_03 AC 48 ms
60,160 KB
testcase_04 AC 48 ms
59,776 KB
testcase_05 AC 47 ms
59,904 KB
testcase_06 AC 47 ms
60,160 KB
testcase_07 AC 46 ms
59,520 KB
testcase_08 AC 53 ms
59,776 KB
testcase_09 AC 53 ms
59,776 KB
testcase_10 AC 53 ms
60,032 KB
testcase_11 AC 71 ms
61,056 KB
testcase_12 AC 71 ms
60,672 KB
testcase_13 AC 66 ms
60,672 KB
testcase_14 AC 69 ms
61,312 KB
testcase_15 AC 69 ms
61,184 KB
testcase_16 AC 71 ms
60,928 KB
testcase_17 AC 74 ms
60,416 KB
testcase_18 AC 67 ms
60,928 KB
testcase_19 AC 66 ms
61,056 KB
testcase_20 AC 65 ms
60,800 KB
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
import collections
#素因数分解
#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())
    P=prime_factorize(N)
    while 2 in P:
        P.remove(2)
    while 5 in P:
        P.remove(5)
    if len(P)==0:
        print(1)
    else:
        
        l = 1
        for p in P:
            l*=p
        temp = 9 % l
        cnt = 1
        while temp!=0:
            temp = (temp*10+9)%l
            cnt+=1

        print(cnt)
0