結果

問題 No.854 公平なりんご分配
ユーザー t33ft33f
提出日時 2019-07-26 22:55:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 71,844 KB
実行使用メモリ 121,996 KB
最終ジャッジ日時 2023-09-15 03:34:06
合計ジャッジ時間 12,577 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 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,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 3 ms
4,384 KB
testcase_24 AC 6 ms
4,584 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 5 ms
4,516 KB
testcase_27 AC 4 ms
4,528 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 5 ms
4,384 KB
testcase_32 AC 29 ms
30,020 KB
testcase_33 AC 46 ms
17,724 KB
testcase_34 AC 72 ms
38,272 KB
testcase_35 AC 49 ms
32,332 KB
testcase_36 AC 51 ms
4,988 KB
testcase_37 AC 29 ms
28,092 KB
testcase_38 AC 22 ms
23,916 KB
testcase_39 AC 126 ms
40,212 KB
testcase_40 AC 57 ms
15,636 KB
testcase_41 AC 53 ms
25,940 KB
testcase_42 AC 60 ms
38,480 KB
testcase_43 AC 92 ms
28,124 KB
testcase_44 AC 87 ms
36,152 KB
testcase_45 AC 112 ms
9,516 KB
testcase_46 AC 122 ms
36,176 KB
testcase_47 AC 41 ms
22,112 KB
testcase_48 AC 53 ms
38,164 KB
testcase_49 AC 48 ms
38,252 KB
testcase_50 AC 24 ms
28,036 KB
testcase_51 AC 120 ms
36,100 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 401 ms
121,860 KB
testcase_84 AC 392 ms
121,768 KB
testcase_85 AC 405 ms
121,804 KB
testcase_86 AC 298 ms
4,380 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 421 ms
121,912 KB
testcase_93 AC 431 ms
121,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        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;
        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