結果
問題 | No.854 公平なりんご分配 |
ユーザー | yuji9511 |
提出日時 | 2019-07-26 23:07:24 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,904 bytes |
コンパイル時間 | 1,526 ms |
コンパイル使用メモリ | 175,252 KB |
実行使用メモリ | 44,416 KB |
最終ジャッジ日時 | 2024-07-02 09:12:23 |
合計ジャッジ時間 | 13,466 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
12,032 KB |
testcase_01 | AC | 4 ms
6,656 KB |
testcase_02 | AC | 5 ms
6,528 KB |
testcase_03 | AC | 5 ms
6,400 KB |
testcase_04 | AC | 4 ms
6,528 KB |
testcase_05 | AC | 4 ms
6,400 KB |
testcase_06 | AC | 4 ms
6,528 KB |
testcase_07 | AC | 4 ms
6,528 KB |
testcase_08 | AC | 4 ms
6,400 KB |
testcase_09 | AC | 5 ms
6,528 KB |
testcase_10 | AC | 4 ms
6,528 KB |
testcase_11 | AC | 4 ms
6,528 KB |
testcase_12 | AC | 4 ms
6,784 KB |
testcase_13 | AC | 4 ms
6,656 KB |
testcase_14 | AC | 4 ms
6,528 KB |
testcase_15 | AC | 4 ms
6,528 KB |
testcase_16 | AC | 4 ms
6,784 KB |
testcase_17 | AC | 5 ms
6,784 KB |
testcase_18 | AC | 4 ms
6,784 KB |
testcase_19 | AC | 5 ms
6,400 KB |
testcase_20 | AC | 4 ms
6,528 KB |
testcase_21 | AC | 4 ms
6,528 KB |
testcase_22 | AC | 7 ms
6,912 KB |
testcase_23 | AC | 7 ms
7,168 KB |
testcase_24 | AC | 8 ms
7,680 KB |
testcase_25 | AC | 6 ms
7,168 KB |
testcase_26 | AC | 10 ms
7,680 KB |
testcase_27 | AC | 7 ms
7,680 KB |
testcase_28 | AC | 7 ms
6,784 KB |
testcase_29 | AC | 5 ms
6,784 KB |
testcase_30 | AC | 6 ms
7,040 KB |
testcase_31 | AC | 9 ms
7,552 KB |
testcase_32 | AC | 67 ms
32,256 KB |
testcase_33 | AC | 86 ms
20,352 KB |
testcase_34 | AC | 153 ms
42,240 KB |
testcase_35 | AC | 104 ms
34,432 KB |
testcase_36 | AC | 72 ms
8,192 KB |
testcase_37 | AC | 61 ms
30,592 KB |
testcase_38 | AC | 44 ms
26,240 KB |
testcase_39 | AC | 246 ms
44,288 KB |
testcase_40 | AC | 101 ms
18,304 KB |
testcase_41 | AC | 106 ms
29,056 KB |
testcase_42 | AC | 131 ms
41,472 KB |
testcase_43 | AC | 172 ms
30,080 KB |
testcase_44 | AC | 176 ms
38,784 KB |
testcase_45 | AC | 190 ms
12,672 KB |
testcase_46 | AC | 236 ms
38,400 KB |
testcase_47 | AC | 78 ms
24,192 KB |
testcase_48 | AC | 121 ms
40,960 KB |
testcase_49 | AC | 110 ms
41,728 KB |
testcase_50 | AC | 55 ms
30,720 KB |
testcase_51 | AC | 234 ms
40,064 KB |
testcase_52 | AC | 146 ms
21,120 KB |
testcase_53 | AC | 66 ms
20,864 KB |
testcase_54 | AC | 141 ms
23,808 KB |
testcase_55 | AC | 43 ms
20,864 KB |
testcase_56 | AC | 38 ms
21,632 KB |
testcase_57 | AC | 67 ms
18,816 KB |
testcase_58 | AC | 155 ms
11,392 KB |
testcase_59 | AC | 33 ms
17,280 KB |
testcase_60 | AC | 100 ms
18,816 KB |
testcase_61 | AC | 48 ms
8,704 KB |
testcase_62 | AC | 122 ms
16,640 KB |
testcase_63 | AC | 77 ms
17,536 KB |
testcase_64 | AC | 31 ms
10,752 KB |
testcase_65 | AC | 92 ms
37,120 KB |
testcase_66 | AC | 68 ms
14,208 KB |
testcase_67 | AC | 107 ms
26,112 KB |
testcase_68 | AC | 112 ms
14,720 KB |
testcase_69 | AC | 74 ms
44,416 KB |
testcase_70 | AC | 36 ms
18,432 KB |
testcase_71 | AC | 42 ms
19,712 KB |
testcase_72 | AC | 99 ms
8,320 KB |
testcase_73 | AC | 61 ms
31,104 KB |
testcase_74 | AC | 138 ms
36,608 KB |
testcase_75 | AC | 72 ms
19,712 KB |
testcase_76 | AC | 105 ms
29,824 KB |
testcase_77 | AC | 113 ms
40,832 KB |
testcase_78 | AC | 154 ms
15,872 KB |
testcase_79 | AC | 135 ms
26,880 KB |
testcase_80 | AC | 126 ms
27,904 KB |
testcase_81 | AC | 86 ms
28,800 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; ll v = P[q]; rep(i,0,prime.size()){ ll cnt = sum[R[q]+1][i] - sum[L[q]][i]; ll idx = 0; while(idx < cnt){ if(v % prime[i] != 0) break; v /= prime[i]; idx++; } } if(v != 1){ ok = false; } // rep(i,0,prime.size()){ // ll cnt = sum[R[q]+1][i] - sum[L[q]][i]; // ll cnt2 = 0; // ll tmp = P[q]; // while(tmp % prime[i] == 0){ // cnt2++; // tmp /= prime[i]; // } // if(cnt2 == 0) continue; // if(cnt2 > cnt){ // ok = false; // } // } if(ok){ print("Yes"); }else{ print("NO"); } } }