結果
問題 | No.854 公平なりんご分配 |
ユーザー | chocopuu |
提出日時 | 2019-07-26 23:47:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,098 bytes |
コンパイル時間 | 1,949 ms |
コンパイル使用メモリ | 186,128 KB |
実行使用メモリ | 486,300 KB |
最終ジャッジ日時 | 2024-07-02 10:07:41 |
合計ジャッジ時間 | 24,570 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 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 | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 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 | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,944 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 7 ms
6,940 KB |
testcase_23 | AC | 5 ms
6,944 KB |
testcase_24 | AC | 9 ms
7,680 KB |
testcase_25 | AC | 5 ms
6,940 KB |
testcase_26 | AC | 9 ms
7,936 KB |
testcase_27 | AC | 6 ms
6,944 KB |
testcase_28 | AC | 6 ms
6,940 KB |
testcase_29 | AC | 3 ms
6,944 KB |
testcase_30 | AC | 5 ms
6,940 KB |
testcase_31 | AC | 10 ms
7,552 KB |
testcase_32 | AC | 79 ms
61,824 KB |
testcase_33 | AC | 110 ms
56,576 KB |
testcase_34 | AC | 187 ms
108,624 KB |
testcase_35 | AC | 132 ms
79,488 KB |
testcase_36 | AC | 114 ms
43,212 KB |
testcase_37 | AC | 76 ms
59,008 KB |
testcase_38 | AC | 57 ms
46,848 KB |
testcase_39 | AC | 329 ms
148,980 KB |
testcase_40 | AC | 134 ms
61,424 KB |
testcase_41 | AC | 131 ms
74,180 KB |
testcase_42 | AC | 156 ms
98,896 KB |
testcase_43 | AC | 219 ms
103,592 KB |
testcase_44 | AC | 215 ms
114,500 KB |
testcase_45 | AC | 252 ms
95,696 KB |
testcase_46 | AC | 301 ms
138,784 KB |
testcase_47 | AC | 102 ms
58,364 KB |
testcase_48 | AC | 142 ms
93,016 KB |
testcase_49 | AC | 134 ms
90,240 KB |
testcase_50 | AC | 71 ms
55,680 KB |
testcase_51 | AC | 290 ms
138,968 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 <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define ALL(a) a.begin(), a.end() const long long MOD = 1e9+7, INF = 1e18; template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;} template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;} vector<int> P; void make_primes(int n) { vector<bool> primes; n++; primes.resize(n, true); primes[0] = primes[1] = false; FOR(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++) primes[i * (j + 2)] = false; FOR(i, 2, n) if (primes[i]) P.push_back(i); } vector<pair<long long, long long> > prime_factorize(long long n) { //計算量は√N!!! vector<pair<long long, long long> > res; for (long long p = 2; p * p <= n; ++p) { if (n % p != 0) continue; int num = 0; while (n % p == 0) { ++num; n /= p; } res.push_back(make_pair(p, num)); } if (n != 1) res.push_back(make_pair(n, 1)); return res; } signed main(){ int N; cin >> N; make_primes(2000); vector<int>inv(2000,0); REP(i,P.size())inv[P[i]] = i; vector<int> a(N); for(auto& e:a)cin >> e; vector<vector<int>>cnt(N+1,vector<int>(P.size(),0)); REP(i,N){ auto tmp = prime_factorize(a[i]); for(auto e:tmp){ cnt[i+1][inv[e.first]] += e.second; } } REP(i,N)REP(j,P.size())cnt[i+1][j] += cnt[i][j]; int Q; cin >> Q; vector<vector<int>>query; vector<int>l(Q),r(Q); vector<int>ans(Q); REP(i,Q){ int p; cin >> p >> l[i] >> r[i]; l[i]--;r[i]--; vector<int>tmp(P.size(),0); REP(j,P.size()){ while(p%P[j] == 0){ p /= P[j]; tmp[inv[P[j]]]++; } } if(p != 1)ans[i] = 1; query.push_back(tmp); } REP(i,Q){ if(ans[i])continue; int flg = 0; REP(j,P.size()){ if(query[i][j]>cnt[r[i]+1][j]-cnt[l[i]][j]){ flg = 1; break; } } ans[i]=flg; } for(auto e:ans){ if(e)cout<<"NO"<<endl; else cout<<"Yes"<<endl; } }