結果

問題 No.2074 Product is Square ?
ユーザー pockynypockyny
提出日時 2022-09-17 20:47:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 67,880 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-23 17:53:36
合計ジャッジ時間 6,388 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 69 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 68 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 68 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 68 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 67 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(a%b,b);
}

ll a[2010];
int main(){
    int t; cin >> t;
    while(t){
        t--;
        int i,j,n; cin >> n;
        for(i=0;i<n;i++) cin >> a[i];
        for(i=0;i<n;i++){
            for(j=i + 1;j<n;j++){
                ll g = gcd(a[i],a[j]);
                a[i] /= g; a[j] /= g;
            }
        }
        bool f = true;
        for(i=0;i<n;i++){
            if(a[i]!=1) f = false;
        }
        if(f) cout << "Yes\n";
        else cout << "No\n";
    }
}
0