結果

問題 No.854 公平なりんご分配
ユーザー りあんりあん
提出日時 2019-07-26 23:12:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,495 bytes
コンパイル時間 2,349 ms
コンパイル使用メモリ 206,784 KB
実行使用メモリ 41,516 KB
最終ジャッジ日時 2023-09-15 04:14:25
合計ジャッジ時間 10,391 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 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 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 5 ms
4,384 KB
testcase_25 AC 3 ms
4,384 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 4 ms
4,384 KB
testcase_32 AC 53 ms
29,140 KB
testcase_33 AC 43 ms
17,076 KB
testcase_34 AC 89 ms
38,988 KB
testcase_35 AC 67 ms
31,244 KB
testcase_36 AC 24 ms
4,760 KB
testcase_37 AC 51 ms
27,468 KB
testcase_38 AC 41 ms
22,816 KB
testcase_39 AC 119 ms
41,516 KB
testcase_40 AC 44 ms
14,964 KB
testcase_41 AC 59 ms
25,688 KB
testcase_42 AC 83 ms
38,420 KB
testcase_43 AC 81 ms
26,676 KB
testcase_44 AC 91 ms
35,820 KB
testcase_45 AC 57 ms
9,508 KB
testcase_46 AC 109 ms
35,172 KB
testcase_47 AC 47 ms
20,936 KB
testcase_48 AC 79 ms
37,828 KB
testcase_49 AC 76 ms
38,552 KB
testcase_50 AC 48 ms
27,384 KB
testcase_51 AC 110 ms
36,872 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>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> primes;
    vector<bool> isprime(2000, true);
    isprime[0] = false;
    isprime[1] = false;
    for (int i = 2; i * i < 2000; ++i) {
        if (isprime[i]) {
            for (int j = i * i; j < 2000; j += i) {
                isprime[j] = false;
            }
        }
    }
    for (int i = 0; i < 2000; ++i) {
        if (isprime[i]) primes.push_back(i);
    }
    int m = primes.size();
    vector<vector<int>> ims(n + 1, vector<int>(m));
    for (int i = 0; i < n; i++) {
        ims[i + 1] = ims[i];
        int p = a[i];
        for (int j = 0; j < m; j++)
        {
            while (p % primes[j] == 0) {
                p /= primes[j];
                ++ims[i + 1][j];
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int p, l, r;
        cin >> p >> l >> r;
        --l;
        for (int j = 0; j < m; j++)
        {
            int c = ims[r][j] - ims[l][j];
            while (p % primes[j] == 0) {
                p /= primes[j];
                --c;
            }
            if (c < 0) {
                p = -1;
                break;
            }
        }
        if (p != 1) {
            cout << "NO\n";
        }
        else {
            cout << "Yes\n";
        }
    }
    return 0;
}
0