結果

問題 No.854 公平なりんご分配
ユーザー 👑 emthrmemthrm
提出日時 2019-07-26 22:56:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,438 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 141,064 KB
実行使用メモリ 40,004 KB
最終ジャッジ日時 2023-09-15 03:38:07
合計ジャッジ時間 16,743 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 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,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 4 ms
4,452 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 5 ms
4,376 KB
testcase_32 AC 75 ms
28,196 KB
testcase_33 AC 93 ms
16,556 KB
testcase_34 AC 192 ms
37,576 KB
testcase_35 AC 124 ms
30,204 KB
testcase_36 AC 34 ms
4,676 KB
testcase_37 AC 72 ms
26,512 KB
testcase_38 AC 52 ms
22,264 KB
testcase_39 AC 319 ms
40,004 KB
testcase_40 AC 100 ms
14,724 KB
testcase_41 AC 131 ms
24,900 KB
testcase_42 AC 160 ms
37,176 KB
testcase_43 AC 218 ms
25,952 KB
testcase_44 AC 221 ms
34,792 KB
testcase_45 AC 106 ms
9,092 KB
testcase_46 AC 313 ms
34,172 KB
testcase_47 AC 94 ms
20,540 KB
testcase_48 AC 143 ms
36,732 KB
testcase_49 AC 133 ms
37,352 KB
testcase_50 AC 65 ms
26,532 KB
testcase_51 AC 303 ms
35,724 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};
/*-------------------------------------------------*/
bool is_prime(long long val) {
  if (val <= 1) return false;
  for (long long i = 2; i * i <= val; ++i) {
    if (val % i == 0) return false;
  }
  return true;
}

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;
}

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

  int n; cin >> n;
  vector<int> primes;
  FOR(i, 1, 2001) {
    if (is_prime(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));
  REP(i, n) {
    REP(j, sz) a[j][i + 1] = a[j][i];
    int ai; cin >> ai;
    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;
    vector<int> range(sz, 0);
    REP(i, sz) range[i] = a[i][r + 1] - a[i][l];
    auto factor = prime_factorization(p);
    bool ok = true;
    for (auto pr : factor) {
      if (pr.first > 2000) {
        ok = false;
        break;
      }
      if (range[mp[pr.first]] < pr.second) {
        ok = false;
        break;
      }
    }
    cout << (ok ? "Yes\n" : "NO\n");
  }
  return 0;
}
0