結果

問題 No.2751 429-like Number
ユーザー norioc
提出日時 2024-05-11 05:44:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,640 ms / 4,000 ms
コード長 524 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 78,856 KB
最終ジャッジ日時 2024-12-20 08:16:34
合計ジャッジ時間 26,265 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt


def primes(n):
    ps = [2]
    t = [True] * (n + 1)
    for i in range(3, n+1, 2):
        if t[i]:
            ps.append(i)
            for j in range(i+i, n+1, i):
                t[j] = False
    return ps


ps = primes(isqrt(10 ** 10) + 10)

Q = int(input())
for _ in range(Q):
    A = int(input())
    x = A
    cnt = 0
    for p in ps:
        while x % p == 0:
            x //= p
            cnt += 1
        if cnt > 3: break

    if x > 1: cnt += 1
    print('Yes' if cnt == 3 else 'No')
0