結果

問題 No.2074 Product is Square ?
ユーザー keisuke6keisuke6
提出日時 2022-09-16 22:08:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 772 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 201,608 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-08-23 15:42:38
合計ジャッジ時間 9,623 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
bool f(int n){
    int l = 0, r = 1e9+7;
    while(r-l > 1){
        int mid = (l+r)/2;
        if(mid*mid <= n) l = mid;
        else r = mid;
    }
    return (l*l==n);
}
signed main(){
    int T;
    cin>>T;
    for(int z=0;z<T;z++){
        int N;
        cin>>N;
        vector<int> S(N);
        for(int i=0;i<N;i++) cin>>S[i];
        for(int i=0;i<70;i++)for(int j=0;j<N;j++)for(int k=j+1;k<N;k++){
            int a = gcd(S[j],S[k]);
            S[j] /= a;
            S[k] /= a;
        }
        bool ok = true;
        for(int i=0;i<N;i++){
            if(!f(S[i])){
                ok = false;
            }
        }
        if(ok) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}
0