結果

問題 No.854 公平なりんご分配
ユーザー ninjaninja
提出日時 2019-07-26 23:31:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 784 ms / 3,153 ms
コード長 1,646 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 175,972 KB
実行使用メモリ 242,388 KB
最終ジャッジ日時 2023-09-15 05:00:59
合計ジャッジ時間 16,034 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,504 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
4,384 KB
testcase_23 AC 4 ms
4,540 KB
testcase_24 AC 7 ms
5,364 KB
testcase_25 AC 4 ms
4,384 KB
testcase_26 AC 7 ms
5,356 KB
testcase_27 AC 5 ms
5,324 KB
testcase_28 AC 5 ms
4,384 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 4 ms
4,388 KB
testcase_31 AC 6 ms
5,064 KB
testcase_32 AC 70 ms
53,720 KB
testcase_33 AC 69 ms
29,916 KB
testcase_34 AC 133 ms
72,744 KB
testcase_35 AC 94 ms
57,900 KB
testcase_36 AC 54 ms
6,188 KB
testcase_37 AC 68 ms
50,548 KB
testcase_38 AC 53 ms
41,496 KB
testcase_39 AC 188 ms
77,036 KB
testcase_40 AC 76 ms
26,364 KB
testcase_41 AC 90 ms
46,952 KB
testcase_42 AC 121 ms
71,312 KB
testcase_43 AC 129 ms
49,036 KB
testcase_44 AC 142 ms
66,316 KB
testcase_45 AC 123 ms
15,192 KB
testcase_46 AC 177 ms
65,296 KB
testcase_47 AC 70 ms
37,912 KB
testcase_48 AC 111 ms
70,316 KB
testcase_49 AC 106 ms
71,856 KB
testcase_50 AC 63 ms
50,212 KB
testcase_51 AC 176 ms
68,844 KB
testcase_52 AC 112 ms
31,528 KB
testcase_53 AC 65 ms
30,948 KB
testcase_54 AC 114 ms
37,004 KB
testcase_55 AC 48 ms
31,232 KB
testcase_56 AC 44 ms
32,592 KB
testcase_57 AC 62 ms
26,760 KB
testcase_58 AC 110 ms
12,728 KB
testcase_59 AC 37 ms
23,804 KB
testcase_60 AC 79 ms
27,128 KB
testcase_61 AC 37 ms
7,512 KB
testcase_62 AC 91 ms
23,332 KB
testcase_63 AC 70 ms
24,488 KB
testcase_64 AC 27 ms
11,272 KB
testcase_65 AC 88 ms
62,944 KB
testcase_66 AC 54 ms
18,032 KB
testcase_67 AC 96 ms
41,528 KB
testcase_68 AC 92 ms
19,092 KB
testcase_69 AC 91 ms
77,204 KB
testcase_70 AC 40 ms
26,572 KB
testcase_71 AC 47 ms
28,772 KB
testcase_72 AC 72 ms
6,416 KB
testcase_73 AC 70 ms
51,356 KB
testcase_74 AC 125 ms
61,880 KB
testcase_75 AC 64 ms
28,944 KB
testcase_76 AC 98 ms
48,868 KB
testcase_77 AC 114 ms
70,076 KB
testcase_78 AC 111 ms
21,168 KB
testcase_79 AC 112 ms
42,564 KB
testcase_80 AC 108 ms
45,040 KB
testcase_81 AC 87 ms
46,956 KB
testcase_82 AC 445 ms
242,296 KB
testcase_83 AC 467 ms
242,176 KB
testcase_84 AC 784 ms
242,120 KB
testcase_85 AC 459 ms
242,120 KB
testcase_86 AC 358 ms
242,388 KB
testcase_87 AC 437 ms
242,208 KB
testcase_88 AC 436 ms
242,128 KB
testcase_89 AC 440 ms
242,212 KB
testcase_90 AC 435 ms
242,168 KB
testcase_91 AC 434 ms
242,172 KB
testcase_92 AC 628 ms
242,176 KB
testcase_93 AC 632 ms
242,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<ll> a(n);

  vector<vector<int>> rs, srs;
  vector<int> zero(n), szero(n + 1);
  vector<ll> p;
  vector<bool> used(2001);
  for (int i = 2; i < 2001; i++) {
    if (used[i]) continue;
    p.push_back(i);
    for (int j = i; j < 2001; j += i) used[j] = true;
  }
  for (int i = 0; i < p.size(); i++) {
    rs.emplace_back(n);
    srs.emplace_back(n + 1);
  }

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      zero[i] = 1;
      continue;
    }
    for (int j = 0; j < p.size() && a[i] > 1; j++) {
      int c = 0;
      while (a[i] % p[j] == 0) {
        a[i] /= p[j];
        c++;
      }
      if (c)
        rs[j][i] = c;
    }
  }
  for (int i = 0; i < n; i++) szero[i + 1] = szero[i] + zero[i];
  for (int i = 0; i < p.size(); i++) for (int j = 0; j < n; j++) srs[i][j + 1] = srs[i][j] + rs[i][j];
  cin >> m;
  for (int i = 0; i < m; i++) {
    ll l, r, q;
    cin >> q >> l >> r;
    l--;
    bool breaked = false;
    if (szero[r] - szero[l]) {
      cout << "Yes" << endl;
      continue;
    }
    for (int j = 0; j < p.size() && q > 1; j++) {
      int c = 0;
      while (q % p[j] == 0) {
        q /= p[j];
        c++;
      }
      if (c && srs[j][r] - srs[j][l] < c) {
        breaked = true;
        break;
      }
    }
    if (!breaked && q == 1) cout << "Yes" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}
0