結果
問題 | No.1250 汝は倍数なりや? |
ユーザー | ryhoh |
提出日時 | 2020-11-16 23:16:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,376 bytes |
コンパイル時間 | 1,848 ms |
コンパイル使用メモリ | 182,444 KB |
実行使用メモリ | 704,060 KB |
最終ジャッジ日時 | 2024-07-23 01:48:33 |
合計ジャッジ時間 | 5,256 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,756 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | WA | - |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 10 ms
6,944 KB |
testcase_24 | AC | 10 ms
6,940 KB |
testcase_25 | AC | 10 ms
6,944 KB |
testcase_26 | AC | 5 ms
6,940 KB |
testcase_27 | AC | 10 ms
6,944 KB |
testcase_28 | AC | 8 ms
6,944 KB |
testcase_29 | AC | 5 ms
6,944 KB |
testcase_30 | AC | 7 ms
6,940 KB |
testcase_31 | AC | 4 ms
6,940 KB |
testcase_32 | AC | 11 ms
6,944 KB |
testcase_33 | MLE | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
ソースコード
#include "bits/stdc++.h" using namespace std; #define rep(i, n) REP(i, 0, n) #define REP(i, k, n) for(auto i = k; i != n; i++) #define rrep(i, n) RREP(i, n, -1) #define RREP(i, n, k) for(auto i = n; i != k; i--) #define debug(x) cerr << #x << " " << x << endl #define print(x) cout << x; #define println(x) cout << x << endl; #define spc << " " << #define mp make_pair #define mt make_tuple #define pf push_front #define pb push_back #define ppf pop_front #define ppb pop_back #define eb emplace_back #define np next_permutation using ll = long long; using Pii = pair<int, int>; using Tiii = tuple<int, int, int>; template<class T>using V = vector<T>; template<class T>using VV = vector<vector<T>>; using Vi = vector<int>; using VVi = vector<vector<int>>; vector<int> primes(int size) { if (size < 0) throw invalid_argument("prime of minus"); vector<int> res; if (size <= 8){ for (int pr : {2, 3, 5, 7}) { if (pr < size) res.push_back(pr); } return res; } bool *opened = new bool[size]; for (int i=0; i<size; ++i) { opened[i] = true; } int limit = (int)sqrt(size); assert(3 <= limit); for (int i=2; i<limit; ++i) { if (opened[i]) { res.push_back(i); for (int j=i; j<size; j+=i) { opened[j] = false; } } } for (int i=limit; i<size; ++i) { if (opened[i]) { res.push_back(i); } } delete[] opened; return res; } // 素因数分解 map<int, int> primeFactors(long long N, const vector<int> &primes) { // check for N if (N < 1) throw invalid_argument("invalid N for zero or minus"); map<int, int> m; if (N == 1) { m.insert(make_pair(1, 1)); return m; } // check for primes if (primes[primes.size()-1] < (int)sqrt(N)) throw invalid_argument("insufficient primes vector"); bool ok = false; while (not ok) { bool end_in_mid = false; for (int prime : primes) { if (N % prime == 0) { m[prime] += 1; N /= prime; end_in_mid = true; break; } if (prime > N) { ok = true; end_in_mid = true; break; } } if (!end_in_mid) { if (N > 1) m[N] = 1; break; } } return m; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, H; cin >> N >> H; std::vector<int> A(N+1); REP(i, 1, N+1) cin >> A[i]; REP(i, 1, N+1) { if (A[i] < 0) A[i] *= -1; else if (A[i] == 0) { cout << "NO" << endl; return 0; } } auto P = primes(H+1); auto base_factors = primeFactors(A[1], P); REP(i, 2, N+1) { const auto add_factors = primeFactors(A[i], P); for (auto iter = add_factors.begin(); iter != add_factors.end(); iter++) { const int key = iter->first; const int val = iter->second; base_factors[key] += val; } } const auto H_factors = primeFactors(H, P); for (auto iter = H_factors.begin(); iter != H_factors.end(); iter++) { const int key = iter->first; const int val = iter->second; if (base_factors[key] < val) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }