結果

問題 No.854 公平なりんご分配
ユーザー merom686merom686
提出日時 2019-07-26 22:24:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,776 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 81,340 KB
実行使用メモリ 121,656 KB
最終ジャッジ日時 2023-09-15 02:08:59
合計ジャッジ時間 11,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 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,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 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
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 339 ms
121,572 KB
testcase_83 AC 339 ms
121,520 KB
testcase_84 AC 341 ms
121,528 KB
testcase_85 AC 366 ms
121,532 KB
testcase_86 AC 241 ms
121,656 KB
testcase_87 AC 362 ms
121,576 KB
testcase_88 AC 364 ms
121,560 KB
testcase_89 AC 359 ms
121,584 KB
testcase_90 AC 363 ms
121,584 KB
testcase_91 AC 364 ms
121,584 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> prime_vector(int n) {
    int m = (int)sqrt(n - 1);

    vector<bool> q(n);
    for (int i = 2; i <= m; i++) {
        if (q[i]) continue;
        for (int j = i * i; j < n; j += i) {
            q[j] = true;
        }
    }

    vector<int> p; p.reserve(n / log(n * 0.329));
    for (int i = 2; i < n; i++) {
        if (!q[i]) p.push_back(i);
    }
    return p;
}

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

    auto pv = prime_vector(2000);
    //cout << pv.size() << endl;
    constexpr int m = 303;
    using B = array<int, m>;

    int n;
    cin >> n;

    vector<B> s(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        for (int j = 0; j < m; j++) {
            int c = 0;
            if (a == 0) {
                c = 30;
            } else {
                while (a % pv[j] == 0) {
                    a /= pv[j];
                    c++;
                }
            }
            s[i + 1][j] = s[i][j] + c;
        }
    }

    int q;
    cin >> q;

    for (int h = 0; h < q; h++) {
        int a, l, r;
        cin >> a >> l >> r;
        l--;

        int b = 1;
        for (int j = 0; j < m; j++) {
            int c = 0;
            if (a == 0) {
                c = 30;
            } else {
                while (a % pv[j] == 0) {
                    a /= pv[j];
                    c++;
                }
            }
            if (s[r][j] - s[l][j] < c) {
                b = 0;
                break;
            }
        }
        cout << (b ? "Yes" : "NO") << '\n';
    }

    return 0;
}
0