結果

問題 No.854 公平なりんご分配
ユーザー t33ft33f
提出日時 2019-07-26 23:00:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 439 ms / 3,153 ms
コード長 1,489 bytes
コンパイル時間 875 ms
コンパイル使用メモリ 76,708 KB
実行使用メモリ 122,016 KB
最終ジャッジ日時 2023-09-15 03:45:04
合計ジャッジ時間 11,910 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,388 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 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 5 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 6 ms
4,572 KB
testcase_25 AC 3 ms
4,384 KB
testcase_26 AC 6 ms
4,576 KB
testcase_27 AC 4 ms
4,640 KB
testcase_28 AC 5 ms
4,384 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 3 ms
4,384 KB
testcase_31 AC 5 ms
4,384 KB
testcase_32 AC 31 ms
30,280 KB
testcase_33 AC 48 ms
17,740 KB
testcase_34 AC 77 ms
38,212 KB
testcase_35 AC 51 ms
32,008 KB
testcase_36 AC 52 ms
4,948 KB
testcase_37 AC 31 ms
27,968 KB
testcase_38 AC 23 ms
24,088 KB
testcase_39 AC 131 ms
40,260 KB
testcase_40 AC 58 ms
15,624 KB
testcase_41 AC 56 ms
25,984 KB
testcase_42 AC 63 ms
38,180 KB
testcase_43 AC 93 ms
27,928 KB
testcase_44 AC 91 ms
36,132 KB
testcase_45 AC 113 ms
9,616 KB
testcase_46 AC 127 ms
36,164 KB
testcase_47 AC 42 ms
21,812 KB
testcase_48 AC 57 ms
38,220 KB
testcase_49 AC 51 ms
38,140 KB
testcase_50 AC 25 ms
27,984 KB
testcase_51 AC 122 ms
36,124 KB
testcase_52 AC 96 ms
17,696 KB
testcase_53 AC 47 ms
17,792 KB
testcase_54 AC 94 ms
21,796 KB
testcase_55 AC 28 ms
17,732 KB
testcase_56 AC 22 ms
19,704 KB
testcase_57 AC 45 ms
15,692 KB
testcase_58 AC 104 ms
9,480 KB
testcase_59 AC 22 ms
15,688 KB
testcase_60 AC 64 ms
15,636 KB
testcase_61 AC 38 ms
7,568 KB
testcase_62 AC 78 ms
13,712 KB
testcase_63 AC 60 ms
15,896 KB
testcase_64 AC 22 ms
7,516 KB
testcase_65 AC 40 ms
34,328 KB
testcase_66 AC 46 ms
11,516 KB
testcase_67 AC 72 ms
23,816 KB
testcase_68 AC 85 ms
11,648 KB
testcase_69 AC 32 ms
40,224 KB
testcase_70 AC 25 ms
15,684 KB
testcase_71 AC 30 ms
17,672 KB
testcase_72 AC 71 ms
5,044 KB
testcase_73 AC 35 ms
27,960 KB
testcase_74 AC 85 ms
34,040 KB
testcase_75 AC 48 ms
17,692 KB
testcase_76 AC 72 ms
27,988 KB
testcase_77 AC 69 ms
38,340 KB
testcase_78 AC 109 ms
13,592 KB
testcase_79 AC 92 ms
23,824 KB
testcase_80 AC 83 ms
25,864 KB
testcase_81 AC 57 ms
25,940 KB
testcase_82 AC 297 ms
121,764 KB
testcase_83 AC 406 ms
121,768 KB
testcase_84 AC 397 ms
121,824 KB
testcase_85 AC 401 ms
121,780 KB
testcase_86 AC 204 ms
4,384 KB
testcase_87 AC 300 ms
121,708 KB
testcase_88 AC 294 ms
122,016 KB
testcase_89 AC 294 ms
121,908 KB
testcase_90 AC 297 ms
121,828 KB
testcase_91 AC 299 ms
121,772 KB
testcase_92 AC 439 ms
121,736 KB
testcase_93 AC 437 ms
121,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;
int B[100100][303] = {};

int main() {
    vector<int> ps;
    vector<bool> b(2001);
    fill(b.begin(), b.end(), true);
    for (int p = 2; p < 2000; p++)
        if (b[p]) {
            ps.push_back(p);
            for (int q = p*p; q < 2000; q += p) b[q] = false;
        }
    assert(ps.size() == 303);

    int n; cin >> n;
    vector<int> zpos;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a == 0) { zpos.push_back(i+1); continue; }
        else 
            for (int k = 0; k < ps.size() && a > 1; k++) {
                int p = ps[k], e = 0;
                while (a % p == 0) { e++; a /= p; }
                if (e > 0)
                    for (int j = i+1; j <= n; j += j&-j) B[j][k] += e;
            }
    }
    int q; cin >> q;
    while (q--) {
        int l, r, x; cin >> x >> l >> r;
        auto it = lower_bound(zpos.begin(), zpos.end(), l);
        if (it != zpos.end() && *it <= r) cout << "Yes" << endl;
        else {
            for (int k = 0; k < ps.size(); k++) {
                int p = ps[k], e = 0;
                if (x % p == 0) {
                    for (int j = r; j > 0; j -= j&-j) e += B[j][k];
                    for (int j = l-1; j > 0; j -= j&-j) e -= B[j][k];
                    while (e > 0 && x % p == 0) x /= p, e--;
                }
            }
            cout << (x == 1 ? "Yes" : "NO") << endl;
        }
    }
}
0