結果

問題 No.854 公平なりんご分配
ユーザー MayimgMayimg
提出日時 2019-07-27 04:05:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,487 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 208,136 KB
実行使用メモリ 243,292 KB
最終ジャッジ日時 2023-09-15 05:44:21
合計ジャッジ時間 15,063 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 4 ms
4,756 KB
testcase_24 AC 6 ms
5,652 KB
testcase_25 AC 3 ms
4,452 KB
testcase_26 AC 6 ms
5,768 KB
testcase_27 AC 6 ms
5,744 KB
testcase_28 AC 3 ms
4,388 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 6 ms
5,388 KB
testcase_32 AC 83 ms
53,948 KB
testcase_33 AC 58 ms
30,372 KB
testcase_34 AC 134 ms
73,280 KB
testcase_35 AC 98 ms
58,152 KB
testcase_36 AC 29 ms
6,628 KB
testcase_37 AC 76 ms
50,824 KB
testcase_38 AC 62 ms
41,792 KB
testcase_39 AC 166 ms
77,428 KB
testcase_40 AC 61 ms
26,408 KB
testcase_41 AC 85 ms
47,100 KB
testcase_42 AC 124 ms
71,944 KB
testcase_43 AC 111 ms
49,284 KB
testcase_44 AC 136 ms
66,928 KB
testcase_45 AC 73 ms
15,596 KB
testcase_46 AC 152 ms
65,808 KB
testcase_47 AC 68 ms
38,208 KB
testcase_48 AC 120 ms
70,820 KB
testcase_49 AC 120 ms
72,468 KB
testcase_50 AC 74 ms
50,296 KB
testcase_51 AC 152 ms
69,516 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 81 ms
37,244 KB
testcase_55 AC 47 ms
31,488 KB
testcase_56 WA -
testcase_57 AC 51 ms
27,152 KB
testcase_58 WA -
testcase_59 AC 35 ms
24,076 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 60 ms
23,452 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 98 ms
63,428 KB
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 113 ms
77,800 KB
testcase_70 AC 40 ms
26,824 KB
testcase_71 AC 44 ms
28,908 KB
testcase_72 WA -
testcase_73 AC 77 ms
51,296 KB
testcase_74 AC 108 ms
62,432 KB
testcase_75 WA -
testcase_76 AC 83 ms
49,072 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 87 ms
45,324 KB
testcase_81 WA -
testcase_82 AC 377 ms
243,288 KB
testcase_83 AC 499 ms
243,216 KB
testcase_84 AC 491 ms
243,272 KB
testcase_85 AC 522 ms
243,228 KB
testcase_86 AC 255 ms
243,212 KB
testcase_87 AC 379 ms
243,292 KB
testcase_88 AC 378 ms
243,224 KB
testcase_89 AC 375 ms
243,288 KB
testcase_90 AC 374 ms
243,240 KB
testcase_91 AC 379 ms
243,148 KB
testcase_92 AC 557 ms
243,232 KB
testcase_93 AC 550 ms
243,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> sieve(int n) {
  vector<int> primes;
  vector<bool> is_prime(n + 1, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    primes.push_back(i);
    for (int j = i + i; j <= n; j += i) {
      is_prime[j] = 0;
    }
  }
  return primes;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  vector<int> primes = sieve(2000);
  int n;
  cin >> n;
  int m = (int) primes.size();
  vector<vector<long long>> cnt(n + 1, vector<long long>(m));
  vector<int> zero(n + 1);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vector<int> tmp(m);
    if (a == 0) {
      zero[i + 1] = zero[i] + 1;
    } else {
      zero[i + 1] = zero[i];
      for (int j = 0; j < m; j++) {
        int c = 0;
        while (a % primes[j] == 0) {
          a /= primes[j];
          c++;
        }
        tmp[j] = c;
      }
    }
    for (int j = 0; j < m; j++) {
      cnt[i + 1][j] = cnt[i][j] + tmp[j];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int p, l, r;
    cin >> p >> l >> r;
    if (zero[l] != zero[r]) {
      puts("Yes");
      continue;
    } 
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int c = 0;
      while (p % primes[j] == 0) {
        p /= primes[j];
        c++;
      }
      ok &= (c <= cnt[r][j] - cnt[l - 1][j]);
    }
    ok &= (p == 1);
    puts(ok ? "Yes" : "NO");
  }
  return 0;
}
0