結果
問題 | No.854 公平なりんご分配 |
ユーザー | jupiro |
提出日時 | 2020-01-26 20:37:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 577 ms / 3,153 ms |
コード長 | 3,311 bytes |
コンパイル時間 | 1,658 ms |
コンパイル使用メモリ | 125,440 KB |
実行使用メモリ | 166,656 KB |
最終ジャッジ日時 | 2024-09-14 11:33:23 |
合計ジャッジ時間 | 12,125 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 5 ms
5,376 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 6 ms
5,376 KB |
testcase_25 | AC | 3 ms
5,376 KB |
testcase_26 | AC | 6 ms
5,376 KB |
testcase_27 | AC | 6 ms
5,376 KB |
testcase_28 | AC | 5 ms
5,376 KB |
testcase_29 | AC | 3 ms
5,376 KB |
testcase_30 | AC | 4 ms
5,376 KB |
testcase_31 | AC | 6 ms
5,376 KB |
testcase_32 | AC | 51 ms
37,760 KB |
testcase_33 | AC | 62 ms
21,912 KB |
testcase_34 | AC | 107 ms
50,944 KB |
testcase_35 | AC | 74 ms
40,704 KB |
testcase_36 | AC | 58 ms
5,760 KB |
testcase_37 | AC | 49 ms
35,840 KB |
testcase_38 | AC | 38 ms
29,696 KB |
testcase_39 | AC | 167 ms
53,888 KB |
testcase_40 | AC | 72 ms
19,260 KB |
testcase_41 | AC | 75 ms
33,280 KB |
testcase_42 | AC | 93 ms
50,176 KB |
testcase_43 | AC | 123 ms
34,688 KB |
testcase_44 | AC | 129 ms
46,720 KB |
testcase_45 | AC | 136 ms
11,904 KB |
testcase_46 | AC | 162 ms
45,952 KB |
testcase_47 | AC | 59 ms
27,008 KB |
testcase_48 | AC | 87 ms
49,664 KB |
testcase_49 | AC | 81 ms
50,560 KB |
testcase_50 | AC | 44 ms
35,584 KB |
testcase_51 | AC | 160 ms
48,384 KB |
testcase_52 | AC | 87 ms
22,928 KB |
testcase_53 | AC | 44 ms
22,584 KB |
testcase_54 | AC | 87 ms
26,624 KB |
testcase_55 | AC | 30 ms
22,712 KB |
testcase_56 | AC | 31 ms
23,680 KB |
testcase_57 | AC | 50 ms
19,772 KB |
testcase_58 | AC | 111 ms
10,112 KB |
testcase_59 | AC | 25 ms
17,792 KB |
testcase_60 | AC | 64 ms
19,788 KB |
testcase_61 | AC | 32 ms
6,656 KB |
testcase_62 | AC | 80 ms
17,152 KB |
testcase_63 | AC | 44 ms
18,048 KB |
testcase_64 | AC | 23 ms
9,088 KB |
testcase_65 | AC | 59 ms
44,416 KB |
testcase_66 | AC | 44 ms
13,932 KB |
testcase_67 | AC | 66 ms
29,696 KB |
testcase_68 | AC | 66 ms
14,720 KB |
testcase_69 | AC | 59 ms
53,888 KB |
testcase_70 | AC | 27 ms
19,456 KB |
testcase_71 | AC | 30 ms
20,968 KB |
testcase_72 | AC | 76 ms
5,888 KB |
testcase_73 | AC | 44 ms
36,096 KB |
testcase_74 | AC | 84 ms
43,648 KB |
testcase_75 | AC | 49 ms
21,084 KB |
testcase_76 | AC | 57 ms
34,688 KB |
testcase_77 | AC | 72 ms
49,280 KB |
testcase_78 | AC | 102 ms
16,000 KB |
testcase_79 | AC | 81 ms
30,336 KB |
testcase_80 | AC | 78 ms
32,000 KB |
testcase_81 | AC | 53 ms
33,152 KB |
testcase_82 | AC | 215 ms
166,656 KB |
testcase_83 | AC | 540 ms
166,656 KB |
testcase_84 | AC | 527 ms
166,656 KB |
testcase_85 | AC | 577 ms
166,656 KB |
testcase_86 | AC | 188 ms
166,656 KB |
testcase_87 | AC | 209 ms
166,656 KB |
testcase_88 | AC | 210 ms
166,528 KB |
testcase_89 | AC | 211 ms
166,528 KB |
testcase_90 | AC | 211 ms
166,656 KB |
testcase_91 | AC | 210 ms
166,656 KB |
testcase_92 | AC | 573 ms
166,528 KB |
testcase_93 | AC | 572 ms
166,656 KB |
ソースコード
#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 = 2050; 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<int>> psum(n + 1, vector<int>(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 { z[i + 1] = z[i]; 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; }