結果

問題 No.854 公平なりんご分配
ユーザー そすうぽよそすうぽよ
提出日時 2019-07-26 22:40:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,120 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 206,400 KB
実行使用メモリ 39,668 KB
最終ジャッジ日時 2023-09-15 02:36:35
合計ジャッジ時間 12,925 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 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 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 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 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 7 ms
4,640 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 7 ms
4,712 KB
testcase_27 AC 5 ms
4,672 KB
testcase_28 AC 5 ms
4,376 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 7 ms
4,388 KB
testcase_32 AC 87 ms
28,060 KB
testcase_33 AC 126 ms
16,444 KB
testcase_34 AC 234 ms
37,648 KB
testcase_35 AC 152 ms
30,164 KB
testcase_36 AC 67 ms
5,004 KB
testcase_37 AC 83 ms
26,472 KB
testcase_38 AC 62 ms
22,572 KB
testcase_39 AC 408 ms
39,668 KB
testcase_40 AC 146 ms
14,640 KB
testcase_41 AC 170 ms
24,892 KB
testcase_42 AC 198 ms
37,080 KB
testcase_43 AC 289 ms
25,724 KB
testcase_44 AC 291 ms
34,392 KB
testcase_45 AC 195 ms
9,176 KB
testcase_46 AC 408 ms
34,308 KB
testcase_47 AC 123 ms
20,188 KB
testcase_48 AC 171 ms
36,664 KB
testcase_49 AC 166 ms
37,348 KB
testcase_50 AC 79 ms
26,564 KB
testcase_51 AC 397 ms
35,800 KB
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

vecint pl(int n) {
  vector<bool> b(n+1, true);
  b[0] = b[1] = false;
  for (int i = 2; i*i <= n; ++i)
    if (b[i])
      for (int j = i*i; j <= n; j += i)
        b[j] = false;
  vecint res;
  REP(i,n+1)
    if (b[i])
      res.push_back(i);
  return res;
}

int main()
{
  int n;
  cin>>n;
  vector<vecint> v(303, vecint(n+1, 0));
  auto pp = pl(2000);
  int np = pp.size();
  REP(i,n) {
    int b;
    cin>>b;
    REP(j,np) {
      v[j][i+1] = v[j][i];
      while ((b % pp[j]) == 0) {
        b /= pp[j];
        ++v[j][i+1];
      }
    }
  }
  int q;
  cin>>q;
  REP(i,q) {
    int p,l,r;
    cin>>p>>l>>r;
    REP(j,303) {
      int d = v[j][r] - v[j][l-1];
      REP(k,d) {
        if ((p % pp[j]) == 0) {
          p /= pp[j];
        } else {
          break;
        }
      }
    }
    if (p == 1) {
      cout << "Yes" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
0