結果
問題 | No.854 公平なりんご分配 |
ユーザー | sntea |
提出日時 | 2019-07-26 22:49:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,124 bytes |
コンパイル時間 | 2,283 ms |
コンパイル使用メモリ | 188,012 KB |
実行使用メモリ | 122,992 KB |
最終ジャッジ日時 | 2024-07-02 08:45:43 |
合計ジャッジ時間 | 18,548 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
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 | 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 | WA | - |
testcase_83 | AC | 773 ms
122,728 KB |
testcase_84 | AC | 737 ms
122,736 KB |
testcase_85 | AC | 471 ms
71,504 KB |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
ソースコード
#pragma GCC optimize ("O3") #ifdef LOCAL111 #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #define _USE_MATH_DEFINES #include <bits/stdc++.h> const int INF = 1e9; using namespace std; template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; } #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define SZ(a) int((a).size()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #ifdef LOCAL111 #define DEBUG(x) cout<<#x<<": "<<(x)<<endl template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} #else #define DEBUG(x) true template<typename T> void dpite(T a, T b){ return; } #endif #define F first #define S second #define SNP string::npos #define WRC(hoge) cout << "Case #" << (hoge)+1 << ": " template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template<typename T> vector<T> make_v(size_t a){return vector<T>(a);} template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); } template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);} template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...); } const array<int, 4> dx = {0, 1, 0, -1}; const array<int, 4> dy = {1, 0, -1, 0}; typedef long long int LL; typedef unsigned long long ULL; typedef pair<int,int> P; void ios_init(){ cout.setf(ios::fixed); cout.precision(12); #ifdef LOCAL111 return; #endif ios::sync_with_stdio(false); cin.tie(0); } std::vector<bool> eratosthenes(int n){ std::vector<bool> res(n+1,true); res[0] = false; res[1] = false; for(long long i = 2; i*i <= n; i++){ for(long long j = 2; i*j <= n; j++){ res[i*j] = false; } } return res; } template<typename T> unordered_map<T,int> primeFactorizem(T x){ unordered_map<T,int> res; for(T i = 2; i*i <= x; i++){ while(x%i == 0){ res[i]++; x /= i; } } if(x != 1) res[x]++; return res; } int main() { ios_init(); int n; while(cin >> n) { vector<int> a(n); REP(i, n) cin >> a[i]; int ma = *max_element(ALL(a)); if(ma == 1) { vector<int> zero_cnt(n+1); REP(i, n) { zero_cnt[i+1] = zero_cnt[i] + (a[i] == 0); } int q; cin >> q; REP(_, q) { int p, l, r; cin >> p >> l >> r; l--; if(p >= 2) { cout << "NO" << endl; } else { if(zero_cnt[r] - zero_cnt[l] == 0) { cout << "Yes" << endl; } else { cout << "NO" << endl; } } } continue; } auto era = eratosthenes(ma); vector<int> pv; REP(i, SZ(era)) if(era[i]) { pv.push_back(i); } vector<vector<int>> imos(SZ(pv), vector<int>(n + 1)); vector<int> zero_cnt(n+1); REP(i, n) { // DEBUG(a[i]); int t = a[i]; if(t == 0) { zero_cnt[i+1]++; continue; } REP(j, SZ(pv)) { while(t % pv[j] == 0) { t /= pv[j]; imos[j][i + 1]++; } } assert(t == 1); // DEBUG(t); } REP(i, n) zero_cnt[i+1] += zero_cnt[i]; REP(i, SZ(pv)) REP(j, n) { imos[i][j+1] += imos[i][j]; } int q; cin >> q; REP(_, q) { // DEBUG(_); LL p; int l, r; cin >> p >> l >> r; l--; if(zero_cnt[r] - zero_cnt[l] != 0) { cout << "NO" << endl; continue; } vector<int> pf(SZ(pv)); REP(i, SZ(pv)) { while(p % pv[i] == 0) { p /= pv[i]; pf[i]++; } } bool ans = true; REP(i, SZ(pv)) { if(pf[i] > imos[i][r] - imos[i][l]) { ans = false; } } if(ans) { cout << "Yes" << endl; } else { cout << "NO" << endl; } } } }