結果
| 問題 | No.2074 Product is Square ? | 
| コンテスト | |
| ユーザー |  NAMIDAIRO | 
| 提出日時 | 2022-09-16 23:07:25 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 462 ms / 2,000 ms | 
| コード長 | 988 bytes | 
| コンパイル時間 | 908 ms | 
| コンパイル使用メモリ | 103,228 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-21 22:38:49 | 
| 合計ジャッジ時間 | 5,990 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 33 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T>
using vi = vector<T>;
template<class T>
using vii = vector<vi<T>>;
template<class T>
using viii = vector<vii<T>>;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
void solve() {
	int n;
	cin >> n;
	vi<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) {
		if (a[i] == 1) continue;
		for (int j = i + 1; j < n; j++) {
			if (a[j] == 1) continue;
			ll g = gcd(a[i], a[j]);
			a[i] /= g;
			a[j] /= g;
		}
	}
	bool ok = true;
	rep(i, n) if (a[i] > 1) {
		ll sq = sqrt(a[i]);
		sq = max<ll>(0, sq - 10);
	    ok = false;
		rep(j, 20) {
			if ((sq + j) * (sq + j) == a[i]) {
				ok = true;
				break;
			}
		}
		if (!ok) break;
	}
	cout << (ok ? "Yes" : "No") << endl;
}
int main()
{
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}
            
            
            
        