結果
問題 | No.2074 Product is Square ? |
ユーザー | 👑 Nachia |
提出日時 | 2022-09-16 22:27:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 425 ms / 2,000 ms |
コード長 | 2,946 bytes |
コンパイル時間 | 852 ms |
コンパイル使用メモリ | 82,888 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-01 13:31:40 |
合計ジャッジ時間 | 5,547 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 5 ms
6,940 KB |
testcase_02 | AC | 5 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,940 KB |
testcase_04 | AC | 5 ms
6,944 KB |
testcase_05 | AC | 4 ms
6,944 KB |
testcase_06 | AC | 4 ms
6,944 KB |
testcase_07 | AC | 4 ms
6,944 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 4 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 36 ms
6,944 KB |
testcase_12 | AC | 114 ms
6,944 KB |
testcase_13 | AC | 425 ms
6,940 KB |
testcase_14 | AC | 114 ms
6,944 KB |
testcase_15 | AC | 36 ms
6,940 KB |
testcase_16 | AC | 119 ms
6,940 KB |
testcase_17 | AC | 425 ms
6,940 KB |
testcase_18 | AC | 111 ms
6,944 KB |
testcase_19 | AC | 35 ms
6,944 KB |
testcase_20 | AC | 121 ms
6,944 KB |
testcase_21 | AC | 423 ms
6,944 KB |
testcase_22 | AC | 112 ms
6,940 KB |
testcase_23 | AC | 36 ms
6,940 KB |
testcase_24 | AC | 120 ms
6,940 KB |
testcase_25 | AC | 419 ms
6,944 KB |
testcase_26 | AC | 109 ms
6,940 KB |
testcase_27 | AC | 35 ms
6,940 KB |
testcase_28 | AC | 118 ms
6,940 KB |
testcase_29 | AC | 425 ms
6,940 KB |
testcase_30 | AC | 111 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 3 ms
6,940 KB |
ソースコード
#line 1 "Main.cpp" #line 2 "nachia\\math\\floor-of-kth-root.hpp" #include <cassert> namespace nachia{ namespace internal{ // mod 2^64 constexpr unsigned long long PowerOfULongLong(unsigned long long a, unsigned long long i){ unsigned long long res = 1; while(i){ if(i&1){ res *= a; } i /= 2; a *= a; } return res; } } unsigned long long FloorOfKthRoot(unsigned long long real, unsigned long long k){ using u64 = unsigned long long; assert(k != 0); if(real <= 1) return real; if(k >= 64) return 1; if(k == 1) return real; struct Precalc{ // a^i <= x static constexpr bool lesseq(u64 a, int i, u64 x) { if (a == 0) return true; for(int j=0; j<i; j++) x /= a; return x >= 1; } unsigned long long BORDER[64]; constexpr Precalc() : BORDER() { for (int idx = 2; idx <= 63; idx++) { u64 l = 0, r = 1ull << 33; while (l + 1 < r) { u64 m = (l + r) / 2; if (lesseq(m, idx, ~0ull)) l = m; else r = m; } BORDER[idx] = r; } }; }; constexpr Precalc precalc; u64 l = 0, r = precalc.BORDER[k]; while (l + 1 < r) { u64 m = (l + r) / 2; if(internal::PowerOfULongLong(m, k) <= real) l = m; else r = m; } return l; } unsigned long long CeilOfKthRoot(unsigned long long real, unsigned long long k){ if(real <= 1) return real; if(k >= 64) return 2; if(k == 1) return real; unsigned long long x = FloorOfKthRoot(real, k); if(internal::PowerOfULongLong(x, k) != real) x++; return x; } } // namespace nachia #line 3 "Main.cpp" #include <iostream> #include <string> #include <vector> #include <algorithm> #include <queue> #include <atcoder/modint> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) using Modint = atcoder::static_modint<998244353>; u64 GCD(u64 a, u64 b){ while(b){ u64 c = a % b; a = b; b = c; } return a; } int main(){ int T; cin >> T; rep(t,T){ int N; cin >> N; vector<u64> A; rep(i,N){ u64 a; cin >> a; for(u64& j : A){ u64 g = GCD(j, a); if(g != 1){ a /= g; j /= g; } } if(a != 1) A.push_back(a); rep(j,A.size()) if(A[j] == 1){ swap(A[j], A.back()); A.pop_back(); j--; } } bool ok = true; for(u64 j : A) if(nachia::FloorOfKthRoot(j,2) * nachia::FloorOfKthRoot(j,2) != j) ok = false; cout << (ok ? "Yes" : "No") << '\n'; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;