結果

問題 No.854 公平なりんご分配
ユーザー rlangevinrlangevin
提出日時 2023-10-23 22:10:28
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,595 bytes
コンパイル時間 6,619 ms
コンパイル使用メモリ 310,176 KB
実行使用メモリ 487,896 KB
最終ジャッジ日時 2023-10-23 22:11:13
合計ジャッジ時間 42,714 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,352 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 2 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 3 ms
5,276 KB
testcase_13 AC 3 ms
5,248 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,400 KB
testcase_16 AC 4 ms
5,216 KB
testcase_17 AC 4 ms
5,496 KB
testcase_18 AC 4 ms
4,964 KB
testcase_19 AC 3 ms
4,964 KB
testcase_20 AC 3 ms
4,872 KB
testcase_21 AC 3 ms
4,964 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 MLE -
testcase_33 WA -
testcase_34 MLE -
testcase_35 MLE -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 TLE -
testcase_40 WA -
testcase_41 WA -
testcase_42 MLE -
testcase_43 WA -
testcase_44 MLE -
testcase_45 WA -
testcase_46 MLE -
testcase_47 WA -
testcase_48 MLE -
testcase_49 MLE -
testcase_50 WA -
testcase_51 MLE -
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++){
        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 && P == 1){
            cout << "Yes" << "\n";
        }
    }
}
0