結果

問題 No.1339 循環小数
コンテスト
ユーザー aaaaaaaaaa2230
提出日時 2021-01-15 22:19:18
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 685 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 707 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 505,480 KB
最終ジャッジ日時 2026-05-21 02:04:54
合計ジャッジ時間 30,051 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 20 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.setrecursionlimit(3*10**5)
t = int(input())
b = {}
for _ in range(t):
    n = int(input())
    dic = {}
    now = 1
    p = n
    for i in range(2,int(p**0.5)+1):
        while n%i == 0:
            n //= i
        if n == 1:
            break
    if n == 1:
        print(1)
        continue
    if n in b:
        print(b[n])
        continue

    while now < n:
        now *= 10
    c = 0
    ans = 1
    while now:
        x,now = divmod(now,n)
        if now in dic:
            ans = c-dic[now]
            break
        dic[now] = c
        now *= 10
        c += 1
        if c >= 3**10**5:
            ans = p-1
            break
    b[n] = ans
    print(ans)
0