結果
問題 | No.854 公平なりんご分配 |
ユーザー | yuji9511 |
提出日時 | 2019-07-26 22:57:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,559 bytes |
コンパイル時間 | 2,467 ms |
コンパイル使用メモリ | 175,236 KB |
実行使用メモリ | 44,416 KB |
最終ジャッジ日時 | 2024-07-02 08:56:58 |
合計ジャッジ時間 | 13,113 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
13,756 KB |
testcase_01 | AC | 5 ms
6,816 KB |
testcase_02 | AC | 5 ms
6,944 KB |
testcase_03 | AC | 5 ms
6,940 KB |
testcase_04 | AC | 4 ms
6,940 KB |
testcase_05 | AC | 4 ms
6,948 KB |
testcase_06 | AC | 4 ms
6,944 KB |
testcase_07 | AC | 5 ms
8,616 KB |
testcase_08 | AC | 5 ms
6,944 KB |
testcase_09 | AC | 4 ms
6,944 KB |
testcase_10 | AC | 5 ms
6,940 KB |
testcase_11 | AC | 5 ms
6,944 KB |
testcase_12 | AC | 4 ms
6,944 KB |
testcase_13 | AC | 4 ms
6,944 KB |
testcase_14 | AC | 5 ms
8,492 KB |
testcase_15 | AC | 4 ms
6,944 KB |
testcase_16 | AC | 4 ms
6,948 KB |
testcase_17 | AC | 5 ms
6,944 KB |
testcase_18 | AC | 4 ms
6,944 KB |
testcase_19 | AC | 5 ms
6,940 KB |
testcase_20 | AC | 5 ms
8,620 KB |
testcase_21 | AC | 5 ms
8,616 KB |
testcase_22 | AC | 7 ms
6,940 KB |
testcase_23 | AC | 6 ms
7,168 KB |
testcase_24 | AC | 8 ms
8,748 KB |
testcase_25 | AC | 5 ms
7,168 KB |
testcase_26 | AC | 8 ms
7,680 KB |
testcase_27 | AC | 7 ms
8,496 KB |
testcase_28 | AC | 6 ms
8,620 KB |
testcase_29 | AC | 5 ms
6,944 KB |
testcase_30 | AC | 6 ms
8,620 KB |
testcase_31 | AC | 7 ms
8,624 KB |
testcase_32 | AC | 61 ms
32,940 KB |
testcase_33 | AC | 56 ms
20,480 KB |
testcase_34 | AC | 117 ms
42,112 KB |
testcase_35 | AC | 76 ms
34,456 KB |
testcase_36 | AC | 45 ms
8,192 KB |
testcase_37 | AC | 61 ms
30,720 KB |
testcase_38 | AC | 45 ms
26,112 KB |
testcase_39 | AC | 158 ms
44,288 KB |
testcase_40 | AC | 56 ms
18,936 KB |
testcase_41 | AC | 67 ms
29,764 KB |
testcase_42 | AC | 104 ms
41,448 KB |
testcase_43 | AC | 105 ms
29,952 KB |
testcase_44 | AC | 119 ms
38,912 KB |
testcase_45 | AC | 95 ms
13,308 KB |
testcase_46 | AC | 146 ms
38,448 KB |
testcase_47 | AC | 57 ms
24,192 KB |
testcase_48 | AC | 95 ms
40,960 KB |
testcase_49 | AC | 93 ms
41,644 KB |
testcase_50 | AC | 56 ms
30,592 KB |
testcase_51 | AC | 145 ms
40,064 KB |
testcase_52 | AC | 103 ms
21,264 KB |
testcase_53 | AC | 57 ms
21,452 KB |
testcase_54 | AC | 102 ms
24,892 KB |
testcase_55 | AC | 38 ms
21,668 KB |
testcase_56 | AC | 32 ms
21,772 KB |
testcase_57 | AC | 51 ms
18,864 KB |
testcase_58 | AC | 91 ms
12,716 KB |
testcase_59 | AC | 29 ms
17,128 KB |
testcase_60 | AC | 70 ms
19,580 KB |
testcase_61 | AC | 38 ms
9,784 KB |
testcase_62 | AC | 77 ms
17,160 KB |
testcase_63 | AC | 70 ms
17,636 KB |
testcase_64 | AC | 25 ms
10,884 KB |
testcase_65 | AC | 78 ms
37,116 KB |
testcase_66 | AC | 51 ms
14,336 KB |
testcase_67 | AC | 94 ms
26,112 KB |
testcase_68 | AC | 88 ms
14,720 KB |
testcase_69 | AC | 83 ms
44,416 KB |
testcase_70 | AC | 36 ms
20,908 KB |
testcase_71 | AC | 40 ms
19,596 KB |
testcase_72 | AC | 61 ms
9,028 KB |
testcase_73 | AC | 57 ms
31,280 KB |
testcase_74 | AC | 130 ms
36,736 KB |
testcase_75 | AC | 54 ms
19,812 KB |
testcase_76 | AC | 95 ms
30,056 KB |
testcase_77 | AC | 111 ms
40,704 KB |
testcase_78 | AC | 98 ms
16,816 KB |
testcase_79 | AC | 104 ms
28,340 KB |
testcase_80 | AC | 100 ms
27,960 KB |
testcase_81 | AC | 75 ms
29,324 KB |
testcase_82 | TLE | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> lpair; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x,y) cout << (x) << " " << (y) << endl; #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];}; int sum[100010][310] = {}; ll is_zero[100010] = {}; struct Integer{ public: Integer(ll n){ } ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} //最大公約数 ll lcm(ll a,ll b){return a / gcd(a, b) * b;} //最小公倍数 bool isPrime(ll x){ if(x < 2) return false; if(x == 2) return true; if(x % 2 == 0) return false; for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false; return true; } vector<ll> divisor(ll M){ //約数の全列挙 vector<ll> dd; for(ll i = 1; i * i <= M; i++){ if(M % i == 0){ dd.push_back(i); if(i * i != M){ dd.push_back(M / i); } } } sort(dd.begin(), dd.end()); return dd; } vector<ll> factor(ll M){ //素因数分解 vector<ll> dd; if(M == 1){ dd.push_back(1); return dd; } for(ll i = 2; i*i <= M; i++){ while(M % i == 0){ dd.push_back(i); M /= i; } } if(M != 1) dd.push_back(M); sort(dd.begin(), dd.end()); return dd; } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll A[100010]; rep(i,0,N) cin >> A[i]; ll Q; cin >> Q; ll P[100010], L[100010], R[100010]; rep(i,0,Q){ cin >> P[i] >> L[i] >> R[i]; L[i]--; R[i]--; } Integer it(0); vector<ll> prime; // prime.push_back(1); rep(i,2,2001){ if(it.isPrime(i)) prime.push_back(i); } map<ll, ll> idx; rep(i,0,prime.size()){ idx[prime[i]] = i; } rep(i,0,N){ if(A[i] == 1 || A[i] == 0) continue; vector<ll> dd = it.factor(A[i]); rep(j,0,dd.size()){ // print(dd[j]); sum[i+1][idx[dd[j]]]++; } } rep(j,0,310){ rep(i,0,N+1){ sum[i+1][j] += sum[i][j]; } } rep(i,0,N){ if(A[i] == 0) is_zero[i+1]++; } rep(i,0,N) is_zero[i+1] += is_zero[i]; // print(sum[3][0] - sum[0][0]); // print(sum[N][0]); // print(idx[2]); // print(idx[3]); rep(q,0,Q){ vector<ll> p = it.factor(P[q]); if(P[q] == 1){ print("Yes"); continue; } ll tt = is_zero[R[q]+1] - is_zero[L[q]]; if(tt > 0){ print("Yes"); continue; } map<ll, ll> mp; rep(i,0,p.size()){ mp[p[i]]++; } bool ok = true; bool is_big = false; for(auto &e: mp){ ll sosuu = e.first; ll num = e.second; if(sosuu > 2000){ is_big = true; break; } ll idx2 = idx[sosuu]; if(sum[R[q]+1][idx2] - sum[L[q]][idx2] < num){ ok = false; } } if(is_big){ print("NO"); }else if(ok){ print("Yes"); }else{ print("NO"); } } }