結果

問題 No.854 公平なりんご分配
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-16 17:19:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,873 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 153,356 KB
実行使用メモリ 126,376 KB
最終ジャッジ日時 2023-09-16 11:03:30
合計ジャッジ時間 10,825 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 5 ms
4,520 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 5 ms
4,784 KB
testcase_27 AC 4 ms
4,660 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 5 ms
4,428 KB
testcase_32 AC 42 ms
29,240 KB
testcase_33 AC 49 ms
16,976 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 42 ms
4,984 KB
testcase_37 WA -
testcase_38 AC 31 ms
22,912 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 38 ms
27,244 KB
testcase_51 WA -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 RE -
testcase_83 AC 362 ms
126,184 KB
testcase_84 WA -
testcase_85 AC 383 ms
126,008 KB
testcase_86 RE -
testcase_87 RE -
testcase_88 RE -
testcase_89 RE -
testcase_90 RE -
testcase_91 RE -
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.16 17:15:34
**/

#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(), 0));
    for (int i = 0; i < n; i++) {
        kosuu[i + 1] = kosuu[i];
        for (int j = 0; j < prime.size(); j++) {
            if (a[i] == 1) break;
            if (a[i] < prime[j]) {
                cerr << "Error!" << 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;
        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