結果

問題 No.854 公平なりんご分配
ユーザー rlangevinrlangevin
提出日時 2023-10-23 22:34:40
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,746 bytes
コンパイル時間 7,320 ms
コンパイル使用メモリ 176,380 KB
実行使用メモリ 76,888 KB
最終ジャッジ日時 2023-10-23 22:35:00
合計ジャッジ時間 17,047 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 5 ms
4,964 KB
testcase_24 AC 8 ms
5,808 KB
testcase_25 AC 4 ms
4,660 KB
testcase_26 AC 7 ms
5,904 KB
testcase_27 AC 6 ms
5,940 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 4 ms
4,580 KB
testcase_31 AC 7 ms
5,572 KB
testcase_32 AC 101 ms
53,656 KB
testcase_33 AC 126 ms
30,160 KB
testcase_34 AC 244 ms
72,664 KB
testcase_35 AC 167 ms
57,880 KB
testcase_36 AC 56 ms
6,400 KB
testcase_37 AC 98 ms
50,488 KB
testcase_38 AC 73 ms
41,512 KB
testcase_39 AC 415 ms
76,888 KB
testcase_40 AC 138 ms
26,200 KB
testcase_41 AC 172 ms
46,792 KB
testcase_42 AC 210 ms
71,344 KB
testcase_43 AC 276 ms
48,904 KB
testcase_44 AC 290 ms
66,328 KB
testcase_45 AC 159 ms
15,376 KB
testcase_46 AC 394 ms
65,272 KB
testcase_47 AC 115 ms
37,816 KB
testcase_48 AC 185 ms
70,288 KB
testcase_49 AC 168 ms
71,872 KB
testcase_50 AC 85 ms
50,224 KB
testcase_51 AC 386 ms
68,704 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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vector<int> Sieve(int n)
{
    vector<int> lst(n + 1, 1);
    vector<int> temp;
    for (int i = 2; i <= n; i++)
    {
        if (lst[i])
        {
            for (int j = 2 * i; j <= n; j += i)
            {
                lst[j] = 0;
            }
        }
    }
    for (int i = 2; i <= n; i++){
        if (lst[i]){
            temp.push_back(i);
        }
    }
    return temp;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> Prime = Sieve(2000);
    int M = (int)Prime.size();
    vector<vector<int>> D(M, vector<int>(N, 0));
    vector<vector<int>> Dc(M, vector<int>(N + 1, 0));
    rep(i, M){
        rep(j, N){
            while (A[j] % Prime[i] == 0){
                A[j] /= Prime[i];
                D[i][j]++;
            }
        }
        rep(j, N){
            Dc[i][j + 1] = Dc[i][j] + D[i][j];
        }
    }
    int Q;
    cin >> Q;
    rep(_, Q){
        int P, L, R;
        int flag = 1;
        cin >> P >> L >> R;
        L--;
        rep(i, M){
            int cnt = 0;
            while (P % Prime[i] == 0){
                cnt++;
                P /= Prime[i];
            }
            if (cnt > Dc[i][R] - Dc[i][L]){
                cout << "NO" << "\n";
                flag = 0;
                break;
            }
        }
        if (flag){
            if (P == 1){
                cout << "Yes" << "\n";
            }
            else{
                cout << "NO" << "\n";
            }
            
        }
    }
}
0