結果

問題 No.854 公平なりんご分配
ユーザー cotton_fn_cotton_fn_
提出日時 2019-07-26 22:34:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,260 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 125,488 KB
実行使用メモリ 814,520 KB
最終ジャッジ日時 2023-09-15 02:28:08
合計ジャッジ時間 5,402 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
10,088 KB
testcase_01 AC 9 ms
10,348 KB
testcase_02 AC 9 ms
10,044 KB
testcase_03 AC 9 ms
10,048 KB
testcase_04 AC 8 ms
10,096 KB
testcase_05 AC 8 ms
10,044 KB
testcase_06 AC 9 ms
10,128 KB
testcase_07 AC 8 ms
10,104 KB
testcase_08 AC 8 ms
10,044 KB
testcase_09 AC 9 ms
10,084 KB
testcase_10 AC 8 ms
10,036 KB
testcase_11 AC 9 ms
10,220 KB
testcase_12 AC 21 ms
25,668 KB
testcase_13 AC 20 ms
24,116 KB
testcase_14 AC 8 ms
10,040 KB
testcase_15 AC 12 ms
14,892 KB
testcase_16 AC 21 ms
24,120 KB
testcase_17 AC 22 ms
27,364 KB
testcase_18 AC 18 ms
21,028 KB
testcase_19 AC 18 ms
21,036 KB
testcase_20 AC 16 ms
19,388 KB
testcase_21 AC 17 ms
20,916 KB
testcase_22 AC 45 ms
52,092 KB
testcase_23 AC 91 ms
120,968 KB
testcase_24 AC 144 ms
191,144 KB
testcase_25 AC 75 ms
95,964 KB
testcase_26 AC 149 ms
199,180 KB
testcase_27 AC 149 ms
202,324 KB
testcase_28 AC 44 ms
50,756 KB
testcase_29 AC 42 ms
55,232 KB
testcase_30 AC 69 ms
89,764 KB
testcase_31 AC 130 ms
172,592 KB
testcase_32 MLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
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;
// 315,000,000
vector<Fenwick<unsigned short>> fs;
int main() {
  cin >> n;
  init_n(fs, 100001, 
      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[x].add(i, 1);
        a /= x;
      }
    }
    if (a > 1) fs[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[x].sum(r) - fs[x].sum(l - 1);
      if (c > s) ok = false;
    }
    cout << (ok ? "Yes" : "NO") << '\n';
  }
  return 0;
}
0