結果

問題 No.854 公平なりんご分配
ユーザー 👑 emthrmemthrm
提出日時 2019-07-26 23:04:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,789 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 142,516 KB
実行使用メモリ 40,444 KB
最終ジャッジ日時 2023-09-15 03:54:04
合計ジャッジ時間 12,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,504 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 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 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 4 ms
4,596 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 4 ms
4,480 KB
testcase_27 AC 4 ms
4,500 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 4 ms
4,500 KB
testcase_32 AC 54 ms
28,436 KB
testcase_33 AC 39 ms
16,876 KB
testcase_34 AC 83 ms
37,972 KB
testcase_35 AC 62 ms
30,612 KB
testcase_36 AC 21 ms
5,088 KB
testcase_37 AC 49 ms
27,032 KB
testcase_38 AC 39 ms
22,712 KB
testcase_39 AC 97 ms
40,392 KB
testcase_40 AC 37 ms
15,084 KB
testcase_41 AC 58 ms
25,304 KB
testcase_42 AC 80 ms
37,516 KB
testcase_43 AC 71 ms
26,304 KB
testcase_44 AC 76 ms
34,944 KB
testcase_45 AC 48 ms
9,416 KB
testcase_46 AC 93 ms
34,376 KB
testcase_47 AC 43 ms
20,560 KB
testcase_48 AC 73 ms
36,976 KB
testcase_49 AC 78 ms
37,712 KB
testcase_50 AC 53 ms
26,728 KB
testcase_51 AC 90 ms
36,136 KB
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
vector<bool> sieve_of_eratosthenes(int num) {
  vector<bool> res(num + 1, true);
  if (num >= 0) {
    res[0] = false;
    if (num >= 1) res[1] = false;
  }
  for (int i = 2; i * i <= num; ++i) if (res[i]) {
    for (int j = i * i; j <= num; j += i) res[j] = false;
  }
  return res;
}

vector<pair<long long, int> > prime_factorization(long long val) {
  vector<pair<long long, int> > res;
  for (long long i = 2; i * i <= val; ++i) {
    if (val % i != 0) continue;
    int exponent = 0;
    while (val % i == 0) {
      ++exponent;
      val /= i;
    }
    res.emplace_back(i, exponent);
  }
  if (val != 1) res.emplace_back(val, 1);
  return res;
}

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<bool> sieve = sieve_of_eratosthenes(2000);
  vector<int> primes;
  FOR(i, 1, 2001) {
    if (sieve[i]) primes.emplace_back(i);
  }
  int sz = primes.size();
  map<int, int> mp;
  REP(i, sz) mp[primes[i]] = i;
  vector<vector<int> > a(sz, vector<int>(n + 1, 0));
  vector<int> zero(n + 1, 0);
  REP(i, n) {
    REP(j, sz) a[j][i + 1] = a[j][i];
    zero[i + 1] = zero[i];
    int ai; cin >> ai;
    if (ai == 0) {
      ++zero[i + 1];
    } else {
      auto p = prime_factorization(ai);
      for (auto pr : p) {
        a[mp[pr.first]][i + 1] += pr.second;
      }
    }
  }
  int q; cin >> q;
  while (q--) {
    int p, l, r; cin >> p >> l >> r; --l; --r;
    auto factor = prime_factorization(p);
    bool ok = true;
    if (zero[r + 1] - zero[l] > 0) {
      ok = false;
    } else {
      for (auto pr : factor) {
        if (pr.first > 2000) {
          ok = false;
          break;
        }
        if (a[mp[pr.first]][r + 1] - a[mp[pr.first]][l] < pr.second) {
          ok = false;
          break;
        }
      }
    }
    cout << (ok ? "Yes\n" : "NO\n");
  }
  return 0;
}
0