結果

問題 No.1339 循環小数
ユーザー GER_chenGER_chen
提出日時 2021-01-22 14:49:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 730 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 8,000 KB
最終ジャッジ日時 2023-08-27 05:26:07
合計ジャッジ時間 11,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#yuki-1339
T = int(input())

for _ in range(T):
    N = int(input())
    while not N%2:
        N //= 2
    while not N%5:
        N //= 5
    i, ans = 3, N
    while i**2 <= N:
        if not N%i:
            ans -= ans//i
            while not N%i:
                N //= i
        i += 2
    if N > 1:
        ans -= ans//N
    if ans < 2:
        print(1)
    else:
        fw, bw = [], []
        j = 1
        while j**2 <= ans:
            if not ans%j:
                fw.append(j)
                bw.append(ans//j)
            j += 1
        d = fw+bw[::-1]
        flag = 0
        i = 0
        while not flag:
            if pow(10, d[i], N) == 1:
                print(d[i])
                flag = 1
            i += 1
0