結果
| 問題 | 
                            No.2751 429-like Number
                             | 
                    
| コンテスト | |
| ユーザー | 
                             detteiuu
                         | 
                    
| 提出日時 | 2024-05-10 21:45:54 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 878 bytes | 
| コンパイル時間 | 358 ms | 
| コンパイル使用メモリ | 82,340 KB | 
| 実行使用メモリ | 77,728 KB | 
| 最終ジャッジ日時 | 2024-12-20 04:55:52 | 
| 合計ジャッジ時間 | 23,726 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 20 WA * 2 | 
ソースコード
Q = int(input())
A = [int(input()) for _ in range(Q)]
def eratosthenes(n):
    sieve = [True] * (n + 1)
    for i in range(int(n**0.5) + 1):
        if i < 2:
            sieve[i] = False
        elif sieve[i]:
            for j in range(2, n//i + 1):
                sieve[i * j] = False
    ans = []
    for i in range(n+1):
        if sieve[i]:
            ans.append(i)
    return ans
prime = eratosthenes(10**5)
D = dict()
for i in range(Q):
    if A[i] in D:
        if D[A[i]] == 3:
            print("Yes")
        else:
            print("No")
        continue
    N = A[i]
    cnt = 0
    idx = 0
    while N >= 2 and idx < len(prime):
        while N % prime[idx] == 0:
            N //= prime[idx]
            cnt += 1
        idx += 1
    if idx == len(prime):
        cnt += 1
    D[A[i]] = cnt
    if cnt == 3:
        print("Yes")
    else:
        print("No")
            
            
            
        
            
detteiuu