結果

問題 No.854 公平なりんご分配
ユーザー kk
提出日時 2021-03-20 20:24:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,271 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 206,072 KB
実行使用メモリ 122,568 KB
最終ジャッジ日時 2023-08-13 14:15:24
合計ジャッジ時間 26,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 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,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 6 ms
4,452 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 6 ms
4,388 KB
testcase_27 AC 5 ms
4,508 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 6 ms
4,376 KB
testcase_32 AC 77 ms
28,424 KB
testcase_33 AC 103 ms
16,416 KB
testcase_34 AC 212 ms
37,848 KB
testcase_35 AC 136 ms
30,460 KB
testcase_36 AC 47 ms
4,728 KB
testcase_37 AC 74 ms
26,732 KB
testcase_38 AC 54 ms
22,272 KB
testcase_39 AC 374 ms
40,056 KB
testcase_40 AC 110 ms
14,664 KB
testcase_41 AC 139 ms
24,928 KB
testcase_42 AC 175 ms
37,416 KB
testcase_43 AC 243 ms
25,932 KB
testcase_44 AC 258 ms
34,688 KB
testcase_45 AC 135 ms
9,072 KB
testcase_46 AC 355 ms
34,152 KB
testcase_47 AC 97 ms
20,468 KB
testcase_48 AC 155 ms
36,748 KB
testcase_49 AC 137 ms
37,588 KB
testcase_50 AC 63 ms
26,684 KB
testcase_51 AC 345 ms
35,948 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 WA -
testcase_83 AC 506 ms
122,560 KB
testcase_84 AC 500 ms
122,412 KB
testcase_85 AC 529 ms
122,516 KB
testcase_86 AC 437 ms
122,532 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,474 ms
122,452 KB
testcase_93 AC 1,473 ms
122,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool isprime(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  
  for (long long i = 3; i * i <= n; i += 2)
    if (n % i == 0)
      return false;
  
  return true;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  vector<vector<int> > factors;
  vector<int> primes;

  for (int p = 0; p < 2000; p++) {
    if (isprime(p)) {
      primes.push_back(p);
      vector<int> f(n+1);
      for (int i = 0; i < n; i++) {
        int b = a[i];
        f[i+1] += f[i];
        while (b > 0 && b % p == 0) {
          b /= p;
          ++f[i+1];
        }
      }
      factors.push_back(f);
    }
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x, l, r;
    cin >> x >> l >> r;
    bool ck = true;
    for (int j = 0; j < primes.size(); j++) {
      int c = 0;
      while (x % primes[j] == 0) {
        x /= primes[j];
        ++c;
      }
      if (c > factors[j][r] - factors[j][l-1]) {
        ck = false;
        break;
      }
    }
    ck &= x == 1;
    if (ck)
      cout << "Yes" << endl;
    else
      cout << "NO" << endl;
  }
  
  return 0;
}
0