結果

問題 No.2751 429-like Number
ユーザー KDKJ
提出日時 2024-06-29 03:24:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 875 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 236,160 KB
最終ジャッジ日時 2024-06-29 03:24:55
合計ジャッジ時間 13,677 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 1 TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict,Counter,deque
from heapq import heappush,heappop


# n以下のすべての素数を列挙する
def eratosthenes_sieve(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = is_prime[1] = False
    primes = set()
    for p in range(2, n + 1):
        if is_prime[p]:
            primes.add(p)
            for q in range(p * p, n + 1, p):
                is_prime[q] = False
    return sorted(list(primes))


def main():
    primes = eratosthenes_sieve(10**7)
    Q = int(input())
    for _ in range(Q):
        a = int(input())
        cnt = 0
        for p in primes:
            while a % p == 0:
                a = a//p
                cnt += 1
        if a > 1:
            cnt += 1
        if cnt == 3:
            print("Yes")
        else:
            print("No")
        
    
    
    



if __name__ == '__main__':
    main()


0