結果

問題 No.2074 Product is Square ?
ユーザー 👑 p-adicp-adic
提出日時 2022-09-16 22:48:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,886 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 201,476 KB
実行使用メモリ 20,660 KB
最終ジャッジ日時 2023-08-23 16:20:48
合計ジャッジ時間 9,323 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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 #

// #define _GLIBCXX_DEBUG 
#include<bits/stdc++.h>
using namespace std;

using uint = unsigned int;
using ll = long long;

#define CIN( LL , A ) LL A; cin >> A 
#define GETLINE( A ) string A; getline( cin , A ) 
#define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) 
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) 
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) 
#define RETURN( ANSWER ) cout << ( ANSWER ) << endl; return 0 
#define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << endl; return 0 
#define MIN( A , B ) A < B ? A : B;
#define MAX( A , B ) A < B ? B : A;

template <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : - a; }

int main()
{
  CIN( ll , T );
  constexpr const ll bound = 1000000000;
  vector<ll> p{};
  p.push_back( 2 );
  ll size = 1;
  FOR( i , 3 , bound ){
    bool prime = true;
    FOR( j , 0 , size ){
      ll& pj = p[j];
      if( i % pj == 0 ){
	prime = false;
	break;
      } else if( pj * pj > i ){
	break;
      }
    }
    if( prime ){
      p.push_back( i );
      size++;
    }
    i++;
  }
  REPEAT( T ){
    CIN( ll , N );
    vector<ll> count( size );
    FOR( i , 0 , N ){
      CIN( ll , Ai );
      FOR( j , 0 , size ){
	ll& pj = p[j];
	if( Ai % pj == 0 ){
	  ll& count_j = count[j];
	  while( Ai % pj == 0 ){
	    Ai /= pj;
	    count_j++;
	  }
	}
      }
    }
    bool square = true;
    FOR( j , 0 , size ){
      if( count[j] % 2 == 1 ){
	square = false;
	break;
      }
    }
    if( square ){
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}
0