結果

問題 No.854 公平なりんご分配
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-16 20:38:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,119 bytes
コンパイル時間 1,233 ms
コンパイル使用メモリ 153,700 KB
実行使用メモリ 126,196 KB
最終ジャッジ日時 2023-09-16 11:08:02
合計ジャッジ時間 13,517 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 5 ms
4,504 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 5 ms
4,548 KB
testcase_27 AC 4 ms
4,564 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 6 ms
4,376 KB
testcase_32 AC 42 ms
29,304 KB
testcase_33 AC 50 ms
16,984 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 45 ms
5,016 KB
testcase_37 WA -
testcase_38 AC 32 ms
22,784 KB
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 AC 37 ms
27,244 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 35 ms
17,580 KB
testcase_56 WA -
testcase_57 AC 48 ms
15,496 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 34 ms
5,764 KB
testcase_62 WA -
testcase_63 AC 64 ms
14,296 KB
testcase_64 AC 23 ms
7,524 KB
testcase_65 AC 56 ms
33,852 KB
testcase_66 WA -
testcase_67 AC 83 ms
22,900 KB
testcase_68 WA -
testcase_69 AC 53 ms
41,308 KB
testcase_70 AC 31 ms
15,156 KB
testcase_71 AC 36 ms
16,276 KB
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 82 ms
26,464 KB
testcase_77 AC 89 ms
37,692 KB
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 AC 352 ms
126,008 KB
testcase_83 AC 369 ms
126,124 KB
testcase_84 WA -
testcase_85 AC 370 ms
126,124 KB
testcase_86 AC 303 ms
126,068 KB
testcase_87 AC 383 ms
126,020 KB
testcase_88 AC 383 ms
126,064 KB
testcase_89 AC 378 ms
126,184 KB
testcase_90 AC 385 ms
126,192 KB
testcase_91 AC 377 ms
126,196 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.16 20:38:06
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector< int > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int N = 2 * 1000;
    vector< bool > isprime(N + 1, true);
    vector< int > prime;
    isprime[0] = isprime[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (isprime[i]) {
            for (int j = i + i; j <= N; j += i) {
                isprime[j] = false;
            }
        }
    }
    for (int i = 2; i <= N; i++) {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }
    vector< vector< int > > kosuu(n + 1, vector< int >(prime.size() + 1, 0));
    for (int i = 0; i < n; i++) {
        kosuu[i + 1] = kosuu[i];
        if (a[i] == 0) {
            kosuu[i + 1][prime.size()]++;
            continue;
        }
        for (int j = 0; j < prime.size(); j++) {
            if (a[i] == 1) break;
            if (a[i] < prime[j]) {
                cerr << "Error!" << a[i] << " " << prime[j] << endl;
                return 1;
            }
            while (a[i] % prime[j] == 0) {
                a[i] /= prime[j];
                kosuu[i + 1][j]++;
            }
        }
    }
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int p, l, r;
        cin >> p >> l >> r;
        if (kosuu[r][prime.size()] - kosuu[l-1][prime.size()] > 0) {
            puts("Yes");
            continue;
        }
        bool ok = false;
        for (int j = 0; j < prime.size(); j++) {
            if (p == 1) {
                puts("Yes");
                ok = true;
                break;
            }
            if (p < prime[j]) {
                break;
            }
            int cnt = 0;
            while (p % prime[j] == 0) {
                cnt++;
                p /= prime[j];
            }   
            if (cnt > kosuu[r][j] - kosuu[l-1][j]) {
                break;
            }
        }
        if (p != 1 || !ok) {
            puts("NO");
        }
    }
    return 0;
}
0