結果

問題 No.854 公平なりんご分配
ユーザー face4face4
提出日時 2019-07-27 01:07:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,311 ms / 3,153 ms
コード長 1,512 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 74,520 KB
実行使用メモリ 122,864 KB
最終ジャッジ日時 2023-09-15 05:25:25
合計ジャッジ時間 15,704 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,388 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,388 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,384 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,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 5 ms
4,548 KB
testcase_25 AC 3 ms
4,384 KB
testcase_26 AC 5 ms
4,732 KB
testcase_27 AC 5 ms
4,676 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 6 ms
4,540 KB
testcase_32 AC 78 ms
28,696 KB
testcase_33 AC 86 ms
16,996 KB
testcase_34 AC 188 ms
38,252 KB
testcase_35 AC 125 ms
30,780 KB
testcase_36 AC 32 ms
5,044 KB
testcase_37 AC 74 ms
27,088 KB
testcase_38 AC 56 ms
22,924 KB
testcase_39 AC 326 ms
40,352 KB
testcase_40 AC 88 ms
15,000 KB
testcase_41 AC 122 ms
25,384 KB
testcase_42 AC 159 ms
37,604 KB
testcase_43 AC 207 ms
26,452 KB
testcase_44 AC 219 ms
35,048 KB
testcase_45 AC 85 ms
9,492 KB
testcase_46 AC 301 ms
34,600 KB
testcase_47 AC 85 ms
21,048 KB
testcase_48 AC 142 ms
37,060 KB
testcase_49 AC 130 ms
37,880 KB
testcase_50 AC 65 ms
26,992 KB
testcase_51 AC 293 ms
36,300 KB
testcase_52 AC 125 ms
17,716 KB
testcase_53 AC 57 ms
17,532 KB
testcase_54 AC 127 ms
20,396 KB
testcase_55 AC 41 ms
17,516 KB
testcase_56 AC 41 ms
18,220 KB
testcase_57 AC 61 ms
15,376 KB
testcase_58 AC 68 ms
8,292 KB
testcase_59 AC 31 ms
13,784 KB
testcase_60 AC 78 ms
15,428 KB
testcase_61 AC 21 ms
5,680 KB
testcase_62 AC 84 ms
13,484 KB
testcase_63 AC 50 ms
14,196 KB
testcase_64 AC 19 ms
7,484 KB
testcase_65 AC 88 ms
33,468 KB
testcase_66 AC 43 ms
10,924 KB
testcase_67 AC 96 ms
22,604 KB
testcase_68 AC 60 ms
11,588 KB
testcase_69 AC 80 ms
40,496 KB
testcase_70 AC 34 ms
15,188 KB
testcase_71 AC 40 ms
16,280 KB
testcase_72 AC 41 ms
5,204 KB
testcase_73 AC 60 ms
27,404 KB
testcase_74 AC 125 ms
32,948 KB
testcase_75 AC 66 ms
16,320 KB
testcase_76 AC 80 ms
26,316 KB
testcase_77 AC 100 ms
37,028 KB
testcase_78 AC 96 ms
12,480 KB
testcase_79 AC 120 ms
23,352 KB
testcase_80 AC 123 ms
24,392 KB
testcase_81 AC 75 ms
25,388 KB
testcase_82 AC 271 ms
122,580 KB
testcase_83 AC 484 ms
122,728 KB
testcase_84 AC 463 ms
122,648 KB
testcase_85 AC 448 ms
122,696 KB
testcase_86 AC 173 ms
122,864 KB
testcase_87 AC 270 ms
122,736 KB
testcase_88 AC 273 ms
122,736 KB
testcase_89 AC 271 ms
122,756 KB
testcase_90 AC 270 ms
122,740 KB
testcase_91 AC 271 ms
122,736 KB
testcase_92 AC 1,311 ms
122,632 KB
testcase_93 AC 1,304 ms
122,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    bool nonp[2000] = {};
    vector<int> p;
    for(int i = 2; i < 2000; i++){
        if(nonp[i]) continue;
        p.push_back(i);
        for(int j = i+i; j < 2000; j += i)  nonp[j] = true;
    }
    int pnum = p.size();

    int n;
    scanf("%d", &n);

    vector<int> a(n);
    for(int i = 0; i < n; i++)  scanf("%d", a.begin()+i);

    vector<vector<int>> sum(pnum, vector<int>(n, 0));
    for(int i = 0; i < pnum; i++){
        for(int j = 0; j < n; j++){
            if(a[j]){
                int tmp = a[j];
                while(tmp%p[i] == 0)    tmp /= p[i], sum[i][j]++;
            }
            if(j)   sum[i][j] += sum[i][j-1];
        }
    }

    vector<int> fuck(n, 0); fuck[0] = (a[0] == 0);
    for(int i = 1; i < n; i++)  fuck[i] = (fuck[i-1] + (a[i]==0));

    int q;
    scanf("%d", &q);

    while(q-- > 0){
        int x, l, r;
        scanf("%d %d %d", &x, &l, &r);
        l--, r--;
        
        if(fuck[r]-(l==0 ? 0 : fuck[l-1])){
            printf("Yes\n");
            continue;
        }

        bool ok = true;
        int tmp = x;
        for(int i = 0; i < pnum; i++){
            int need = 0;
            while(tmp%p[i]==0)  tmp /= p[i], need++;
            int exist = sum[i][r] - (l==0 ? 0 : sum[i][l-1]);
            if(need > exist)    ok = false;
        }
        ok &= (tmp == 1);

        if(ok)  printf("Yes\n");
        else    printf("NO\n");
    }

    return 0;
}
0