結果
問題 |
No.2074 Product is Square ?
|
ユーザー |
![]() |
提出日時 | 2023-08-04 00:18:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 456 ms / 2,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 70,528 KB |
最終ジャッジ日時 | 2024-10-13 21:20:37 |
合計ジャッジ時間 | 9,132 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
import sys input = sys.stdin.readline from math import gcd def is_sqrt(n): yes = 0 no = 10 ** 9 + 5 while no - yes != 1: mid = (yes + no)//2 if n >= mid * mid: yes = mid else: no = mid return n == yes * yes T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, input().split())) for i in range(N): for j in range(i + 1, N): g = gcd(A[i], A[j]) A[i] //= g A[j] //= g ans = 1 for a in A: ans &= is_sqrt(a) print("Yes") if ans else print("No")