結果

問題 No.854 公平なりんご分配
ユーザー mencottonmencotton
提出日時 2019-07-26 23:03:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,823 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 74,596 KB
実行使用メモリ 251,884 KB
最終ジャッジ日時 2023-09-15 03:52:18
合計ジャッジ時間 23,270 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,352 KB
testcase_01 AC 13 ms
8,280 KB
testcase_02 AC 12 ms
8,252 KB
testcase_03 AC 13 ms
8,240 KB
testcase_04 AC 12 ms
8,196 KB
testcase_05 AC 13 ms
8,320 KB
testcase_06 AC 13 ms
8,272 KB
testcase_07 AC 13 ms
8,184 KB
testcase_08 AC 12 ms
8,212 KB
testcase_09 AC 13 ms
8,188 KB
testcase_10 AC 12 ms
8,268 KB
testcase_11 AC 12 ms
8,464 KB
testcase_12 AC 13 ms
8,428 KB
testcase_13 AC 13 ms
8,436 KB
testcase_14 AC 13 ms
8,240 KB
testcase_15 AC 13 ms
8,332 KB
testcase_16 AC 13 ms
8,448 KB
testcase_17 AC 13 ms
8,496 KB
testcase_18 AC 13 ms
8,596 KB
testcase_19 AC 13 ms
8,548 KB
testcase_20 AC 13 ms
8,316 KB
testcase_21 AC 13 ms
8,468 KB
testcase_22 AC 17 ms
8,720 KB
testcase_23 AC 16 ms
9,744 KB
testcase_24 AC 20 ms
10,536 KB
testcase_25 AC 15 ms
9,276 KB
testcase_26 AC 20 ms
10,724 KB
testcase_27 AC 17 ms
10,648 KB
testcase_28 AC 18 ms
8,856 KB
testcase_29 AC 15 ms
8,884 KB
testcase_30 AC 15 ms
9,264 KB
testcase_31 AC 20 ms
10,480 KB
testcase_32 AC 86 ms
59,592 KB
testcase_33 AC 110 ms
35,516 KB
testcase_34 AC 181 ms
79,048 KB
testcase_35 AC 127 ms
64,068 KB
testcase_36 AC 106 ms
11,628 KB
testcase_37 AC 82 ms
56,296 KB
testcase_38 AC 65 ms
47,128 KB
testcase_39 AC 283 ms
83,468 KB
testcase_40 AC 130 ms
31,648 KB
testcase_41 AC 132 ms
52,600 KB
testcase_42 AC 157 ms
77,812 KB
testcase_43 AC 207 ms
54,644 KB
testcase_44 AC 209 ms
72,596 KB
testcase_45 AC 236 ms
20,864 KB
testcase_46 AC 275 ms
71,732 KB
testcase_47 AC 103 ms
43,280 KB
testcase_48 AC 143 ms
76,656 KB
testcase_49 AC 132 ms
78,300 KB
testcase_50 AC 75 ms
56,156 KB
testcase_51 AC 273 ms
75,076 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 AC 805 ms
251,640 KB
testcase_83 AC 850 ms
251,576 KB
testcase_84 AC 846 ms
251,672 KB
testcase_85 AC 894 ms
251,572 KB
testcase_86 AC 805 ms
251,776 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 930 ms
251,848 KB
testcase_93 AC 930 ms
251,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

#define int long long
using namespace std;

int PRIME_SIZE;
int MAX_APPLE = 2019;

signed main() {
    vector<int> prime;
    for (int i = 2; i <= MAX_APPLE; i++) {
        bool flag = true;
        for (auto x:prime) {
            if (x * x > i)break;
            if (i % x == 0)flag = false;
        }
        if (flag)prime.push_back(i);
    }
    PRIME_SIZE = prime.size();

    vector<vector<int>> factoring(MAX_APPLE + 1, vector<int>(PRIME_SIZE));
    for (int i = 1; i <= MAX_APPLE; i++) {
        int x = i;
        for (int j = 0; j < PRIME_SIZE; j++) {
            while (x % prime[j] == 0) {
                x /= prime[j];
                factoring[i][j]++;
            }
        }
    }

    int n;
    cin >> n;

    vector<vector<int>> cumulative_sum(n + 1, vector<int>(PRIME_SIZE));
    int zero_count[n + 1];
    for (int i = 1; i <= n; i++) {
        int now;
        cin >> now;
        for (int j = 0; j < PRIME_SIZE; j++) cumulative_sum[i][j] = cumulative_sum[i - 1][j] + factoring[now][j];
        zero_count[i] = zero_count[i - 1] + (now == 0);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int p, l, r;
        cin >> p >> l >> r;

        vector<int> needed(PRIME_SIZE);
        for (int j = 0; j < PRIME_SIZE; j++) {
            while (p % prime[j] == 0) {
                p /= prime[j];
                needed[j]++;
            }
        }
        if (p != 1) {
            cout << (zero_count[r] - zero_count[l - 1] ? "Yes" : "NO") << endl;
            continue;
        }

        bool ret = true;
        for (int j = 0; j < PRIME_SIZE; j++) {
            if (cumulative_sum[r][j] - cumulative_sum[l - 1][j] < needed[j])
                ret = false;
        }
        cout << (ret ? "Yes" : "NO") << endl;
    }
    return 0;
}
0