結果

問題 No.854 公平なりんご分配
ユーザー cotton_fn_cotton_fn_
提出日時 2019-07-26 22:43:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,553 bytes
コンパイル時間 1,467 ms
コンパイル使用メモリ 135,672 KB
実行使用メモリ 609,740 KB
最終ジャッジ日時 2023-09-15 03:12:16
合計ジャッジ時間 18,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 5 ms
4,392 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 6 ms
4,444 KB
testcase_12 AC 7 ms
5,680 KB
testcase_13 AC 7 ms
5,728 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 5 ms
4,612 KB
testcase_16 AC 6 ms
5,608 KB
testcase_17 AC 7 ms
5,996 KB
testcase_18 AC 7 ms
5,212 KB
testcase_19 AC 6 ms
5,540 KB
testcase_20 AC 6 ms
5,096 KB
testcase_21 AC 6 ms
5,224 KB
testcase_22 AC 14 ms
8,332 KB
testcase_23 AC 18 ms
15,204 KB
testcase_24 AC 27 ms
22,360 KB
testcase_25 AC 15 ms
12,740 KB
testcase_26 AC 27 ms
23,088 KB
testcase_27 AC 26 ms
23,428 KB
testcase_28 AC 14 ms
8,252 KB
testcase_29 AC 11 ms
8,840 KB
testcase_30 AC 15 ms
12,268 KB
testcase_31 AC 25 ms
20,492 KB
testcase_32 MLE -
testcase_33 AC 279 ms
225,172 KB
testcase_34 MLE -
testcase_35 MLE -
testcase_36 AC 127 ms
30,600 KB
testcase_37 MLE -
testcase_38 MLE -
testcase_39 MLE -
testcase_40 AC 290 ms
192,848 KB
testcase_41 MLE -
testcase_42 MLE -
testcase_43 MLE -
testcase_44 MLE -
testcase_45 AC 312 ms
103,344 KB
testcase_46 MLE -
testcase_47 AC 332 ms
287,572 KB
testcase_48 MLE -
testcase_49 MLE -
testcase_50 MLE -
testcase_51 MLE -
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class T, class F = plus<T>>
struct Fenwick {
  i64 n;
  vector<T> c;
  F f;
  Fenwick(i64 n, F f = plus<T>(), T init = T())
    : n(n), c(n + 1, init), f(f) {}
  T sum(i64 i) {
    return i > 0 ? f(sum(i - (i & -i)), c[i]) : T();
  }
  void add(i64 i, i64 x) {
    if (i <= n) {
      c[i] = f(c[i], x);
      add(i + (i & -i), x);
    }
  }
};
template<class T, class F>
Fenwick<T, F> make_fenwick(i64 n, F f, T init = T()) {
  return Fenwick<T, F>(n, f, init);
}
i64 n;
vector<Fenwick<unsigned short>> fs;
int main() {
  cin >> n;
  vector<bool> serve(100001, true);
  for (int x = 2; x <= 100001; ++x) {
    if (serve[x]) {
      for (int y = 2 * x; y <= 100001; y += x) serve[y] = false;
    }
  }
  map<int, int> pmp;
  for (int x = 2; x <= 100001; ++x) {
    if (serve[x]) {
      pmp[x] = pmp.size() + 1;
    }
  }
  init_n(fs, 10001, 
      make_fenwick(n, plus<unsigned short>(), (unsigned short)0));
  for (i64 i = 1; i <= n; ++i) {
    i64 a; cin >> a;
    for (i64 x = 2; x <= 330; ++x) {
      while (a % x == 0) {
        fs[pmp[x]].add(i, 1);
        a /= x;
      }
    }
    if (a > 1) fs[pmp[a]].add(i, 1);
  }
  
  i64 q;
  cin >> q;
  while (q--) {
    i64 p, l, r;
    cin >> p >> l >> r;
    if (p == 1) {
      cout << "Yes\n";
      continue;
    }
    map<i64, i64> mp;
    for (int x = 2; x <= 330; ++x) {
      while (p % x == 0) {
        mp[x]++;
        p /= x;
      }
    }
    if (p > 1) mp[p]++;
    bool ok = true;
    for (auto e : mp) {
      i64 x = e.first, c = e.second;
      i64 s = fs[pmp[x]].sum(r) - fs[pmp[x]].sum(l - 1);
      if (c > s) ok = false;
    }
    cout << (ok ? "Yes" : "NO") << '\n';
  }
  return 0;
}
0