結果
| 問題 |
No.2751 429-like Number
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2024-05-10 21:53:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,615 ms / 4,000 ms |
| コード長 | 897 bytes |
| コンパイル時間 | 548 ms |
| コンパイル使用メモリ | 82,252 KB |
| 実行使用メモリ | 78,084 KB |
| 最終ジャッジ日時 | 2024-12-20 05:15:31 |
| 合計ジャッジ時間 | 24,141 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 22 |
ソースコード
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+300)
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 N >= 2 and idx == len(prime):
cnt += 1
D[A[i]] = cnt
if cnt == 3:
print("Yes")
else:
print("No")
detteiuu