結果

問題 No.1339 循環小数
ユーザー titiatitia
提出日時 2021-01-15 22:29:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 77,248 KB
最終ジャッジ日時 2023-08-17 17:49:14
合計ジャッジ時間 5,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,212 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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 178 ms
76,428 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

import math

def fac(x):
    L=int(math.sqrt(x))

    FACT=dict()

    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1
    return FACT

def faclist(x):  
    xr=math.ceil(math.sqrt(x))

    LIST=[]
    for i in range(1,xr+1):
        if x%i==0:
            LIST.append(i)
            LIST.append(x//i)

    return sorted(set(LIST))

T=int(input())
for tests in range(T):
    N=int(input())

    while N%2==0:
        N//=2

    while N%5==0:
        N//=5

    if N==1:
        print(1)
        continue
    F=fac(N)
    ANS=1
    for f in F:
        for i in faclist(f-1):
            if pow(10,i,f)==1:
                ANS*=i**F[f]
                break

    print(ANS)

    

    
    
0