結果
問題 | No.854 公平なりんご分配 |
ユーザー | jupiro |
提出日時 | 2020-01-26 20:11:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,257 bytes |
コンパイル時間 | 1,520 ms |
コンパイル使用メモリ | 123,580 KB |
実行使用メモリ | 291,456 KB |
最終ジャッジ日時 | 2024-09-14 11:26:22 |
合計ジャッジ時間 | 45,302 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 171 ms
52,072 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | RE | - |
testcase_27 | WA | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | WA | - |
testcase_33 | RE | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | RE | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | RE | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | RE | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | RE | - |
testcase_59 | WA | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | RE | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | RE | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | RE | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | TLE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | AC | 380 ms
291,300 KB |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
ソースコード
#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]; ll MinFactor[MAX]; vector<ll> preprocess(ll n = MAX) { vector<ll> 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() + 1)); 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) continue; 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 { vector<pair<ll, ll>> vp = fast_prime_factor(x); if (x == 1) puts("Yes"); else { bool flag = true; for (auto p : vp) { ll cnt = psum[r][cnv[p.first]] - psum[l - 1][cnv[p.first]]; if (cnt < p.second) flag = false; } if (flag) puts("Yes"); else puts("No"); } } } return 0; }