結果
問題 | No.854 公平なりんご分配 |
ユーザー | yuji9511 |
提出日時 | 2019-07-26 22:53:34 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,373 bytes |
コンパイル時間 | 1,481 ms |
コンパイル使用メモリ | 175,112 KB |
実行使用メモリ | 45,872 KB |
最終ジャッジ日時 | 2024-07-02 08:50:31 |
合計ジャッジ時間 | 11,776 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
8,620 KB |
testcase_01 | AC | 4 ms
6,816 KB |
testcase_02 | AC | 5 ms
8,616 KB |
testcase_03 | AC | 4 ms
8,616 KB |
testcase_04 | AC | 5 ms
8,616 KB |
testcase_05 | AC | 5 ms
8,492 KB |
testcase_06 | AC | 4 ms
8,616 KB |
testcase_07 | AC | 4 ms
8,620 KB |
testcase_08 | AC | 4 ms
8,616 KB |
testcase_09 | AC | 4 ms
8,492 KB |
testcase_10 | AC | 5 ms
8,616 KB |
testcase_11 | AC | 4 ms
8,488 KB |
testcase_12 | AC | 4 ms
8,620 KB |
testcase_13 | AC | 4 ms
8,616 KB |
testcase_14 | AC | 4 ms
8,620 KB |
testcase_15 | AC | 4 ms
8,616 KB |
testcase_16 | AC | 4 ms
8,620 KB |
testcase_17 | AC | 4 ms
8,624 KB |
testcase_18 | AC | 4 ms
8,488 KB |
testcase_19 | AC | 4 ms
8,616 KB |
testcase_20 | AC | 5 ms
8,616 KB |
testcase_21 | AC | 4 ms
8,620 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 | 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[1000010] = {}; 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,2010){ 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; for(auto &e: mp){ ll sosuu = e.first; ll num = e.second; ll idx2 = idx[sosuu]; if(sum[R[q]+1][idx2] - sum[L[q]][idx2] < num){ ok = false; } } if(ok){ print("Yes"); }else{ print("NO"); } } }