結果

問題 No.854 公平なりんご分配
ユーザー ninjaninja
提出日時 2019-07-26 23:29:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,636 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 176,892 KB
実行使用メモリ 242,260 KB
最終ジャッジ日時 2023-09-15 04:54:55
合計ジャッジ時間 15,879 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,388 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 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,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 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 AC 434 ms
242,176 KB
testcase_83 AC 466 ms
242,236 KB
testcase_84 AC 777 ms
242,168 KB
testcase_85 AC 454 ms
242,156 KB
testcase_86 AC 354 ms
242,216 KB
testcase_87 AC 439 ms
242,164 KB
testcase_88 AC 434 ms
242,260 KB
testcase_89 AC 435 ms
242,156 KB
testcase_90 AC 435 ms
242,256 KB
testcase_91 AC 436 ms
242,216 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

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) cout << "Yes" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}
0