結果
問題 | No.854 公平なりんご分配 |
ユーザー | jupiro |
提出日時 | 2020-01-26 20:35:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,283 bytes |
コンパイル時間 | 1,488 ms |
コンパイル使用メモリ | 124,932 KB |
実行使用メモリ | 347,924 KB |
最終ジャッジ日時 | 2024-09-14 11:33:10 |
合計ジャッジ時間 | 29,786 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
30,224 KB |
testcase_01 | AC | 118 ms
30,228 KB |
testcase_02 | AC | 116 ms
30,228 KB |
testcase_03 | AC | 123 ms
30,224 KB |
testcase_04 | AC | 131 ms
30,100 KB |
testcase_05 | AC | 126 ms
30,104 KB |
testcase_06 | AC | 120 ms
30,232 KB |
testcase_07 | AC | 122 ms
30,228 KB |
testcase_08 | AC | 127 ms
30,232 KB |
testcase_09 | AC | 130 ms
30,228 KB |
testcase_10 | AC | 123 ms
30,224 KB |
testcase_11 | AC | 125 ms
30,104 KB |
testcase_12 | AC | 121 ms
30,104 KB |
testcase_13 | AC | 132 ms
30,228 KB |
testcase_14 | AC | 128 ms
30,224 KB |
testcase_15 | AC | 124 ms
30,228 KB |
testcase_16 | AC | 138 ms
30,104 KB |
testcase_17 | AC | 120 ms
30,232 KB |
testcase_18 | AC | 126 ms
30,224 KB |
testcase_19 | AC | 124 ms
30,104 KB |
testcase_20 | AC | 127 ms
30,228 KB |
testcase_21 | AC | 131 ms
30,224 KB |
testcase_22 | AC | 131 ms
30,228 KB |
testcase_23 | AC | 132 ms
30,356 KB |
testcase_24 | AC | 126 ms
31,504 KB |
testcase_25 | AC | 131 ms
30,224 KB |
testcase_26 | AC | 136 ms
31,504 KB |
testcase_27 | AC | 130 ms
31,632 KB |
testcase_28 | AC | 127 ms
30,232 KB |
testcase_29 | AC | 129 ms
30,100 KB |
testcase_30 | AC | 127 ms
30,228 KB |
testcase_31 | AC | 127 ms
31,120 KB |
testcase_32 | AC | 206 ms
96,016 KB |
testcase_33 | AC | 195 ms
64,640 KB |
testcase_34 | AC | 273 ms
121,612 KB |
testcase_35 | AC | 221 ms
101,808 KB |
testcase_36 | AC | 184 ms
33,040 KB |
testcase_37 | AC | 197 ms
91,788 KB |
testcase_38 | AC | 173 ms
79,892 KB |
testcase_39 | AC | 331 ms
127,508 KB |
testcase_40 | AC | 214 ms
59,276 KB |
testcase_41 | AC | 212 ms
87,056 KB |
testcase_42 | AC | 250 ms
120,208 KB |
testcase_43 | AC | 259 ms
89,872 KB |
testcase_44 | AC | 284 ms
113,172 KB |
testcase_45 | AC | 274 ms
44,816 KB |
testcase_46 | AC | 311 ms
112,140 KB |
testcase_47 | AC | 213 ms
74,768 KB |
testcase_48 | AC | 251 ms
118,632 KB |
testcase_49 | AC | 245 ms
120,592 KB |
testcase_50 | AC | 198 ms
91,408 KB |
testcase_51 | AC | 322 ms
116,492 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | MLE | - |
testcase_83 | MLE | - |
testcase_84 | MLE | - |
testcase_85 | MLE | - |
testcase_86 | MLE | - |
testcase_87 | MLE | - |
testcase_88 | MLE | - |
testcase_89 | MLE | - |
testcase_90 | MLE | - |
testcase_91 | MLE | - |
testcase_92 | MLE | - |
testcase_93 | MLE | - |
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> #include <iomanip> #include <limits> #include <chrono> #include <random> #include <array> #include <unordered_map> #include <functional> #include <complex> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; bool IsPrime[MAX]; int MinFactor[MAX]; vector<int> preprocess(ll n = MAX) { vector<int> res; for (ll i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1; IsPrime[0] = false; IsPrime[1] = false; MinFactor[0] = 0; MinFactor[1] = 1; for (ll i = 2; i < n; ++i) { if (IsPrime[i]) { MinFactor[i] = i; res.push_back(i); for (ll j = i * 2; j < n; j += i) { IsPrime[j] = false; if (MinFactor[j] == -1) MinFactor[j] = i; } } } return res; } vector<pair<ll, ll> > fast_prime_factor(ll n) { vector<pair<ll, ll> > res; while (n != 1) { ll prime = MinFactor[n]; ll exp = 0; while (MinFactor[n] == prime) { ++exp; n /= prime; } res.push_back(make_pair(prime, exp)); } return res; } ll cnv[2001]; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ preprocess(); vector<ll> pr; { ll idx = 0; for (ll i = 2; i <= 2000; i++) { if (IsPrime[i]) { pr.push_back(i); cnv[i] = idx++; } } } ll n; scanf("%lld", &n); vector<ll> a(n); for (ll i = 0; i < n; i++) scanf("%lld", &a[i]); vector<vector<ll>> psum(n + 1, vector<ll>(pr.size() + 100)); vector<ll> z(n + 1); for (ll i = 0; i < n; i++) { if (a[i] == 0) z[i + 1] = z[i] + 1; else { if (a[i] != 1) { vector<pair<ll, ll>> vp = fast_prime_factor(a[i]); for (auto p : vp) { psum[i + 1][cnv[p.first]] += p.second; } } } for (ll j = 0; j < psum[i].size(); j++) { psum[i + 1][j] += psum[i][j]; } } ll Q; scanf("%lld", &Q); while (Q--) { ll x, l, r; scanf("%lld %lld %lld", &x, &l, &r); if (z[r] - z[l - 1] > 0) puts("Yes"); else { if (x == 1) puts("Yes"); else { for (ll e: pr) { if (x % e != 0) continue; ll cnt = psum[r][cnv[e]] - psum[l - 1][cnv[e]]; for (ll i = 0; i < cnt && (x % e == 0); i++) { x /= e; } } if (x == 1) puts("Yes"); else puts("NO"); } } } return 0; }