結果

問題 No.854 公平なりんご分配
ユーザー maspymaspy
提出日時 2020-03-18 15:06:34
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,551 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 143,908 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-20 19:56:54
合計ジャッジ時間 10,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,316 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 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,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 39 ms
4,376 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 76 ms
4,376 KB
testcase_35 AC 54 ms
4,380 KB
testcase_36 AC 37 ms
4,380 KB
testcase_37 AC 37 ms
4,380 KB
testcase_38 AC 30 ms
4,376 KB
testcase_39 AC 112 ms
4,376 KB
testcase_40 AC 47 ms
4,376 KB
testcase_41 AC 53 ms
4,376 KB
testcase_42 AC 68 ms
4,376 KB
testcase_43 AC 79 ms
4,380 KB
testcase_44 AC 84 ms
4,380 KB
testcase_45 AC 81 ms
4,380 KB
testcase_46 AC 107 ms
4,380 KB
testcase_47 AC 41 ms
4,376 KB
testcase_48 AC 62 ms
4,376 KB
testcase_49 AC 59 ms
4,376 KB
testcase_50 AC 35 ms
4,380 KB
testcase_51 AC 106 ms
4,376 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>
using namespace std;

#define U 100010
int A[U];
int P[U];
int L[U];
int R[U];
int ord_A[U];
bool is_prime[2010];
bool ok[U];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        ok[i] = true;
        cin >> P[i];
        cin >> L[i];
        cin >> R[i];
    }
    is_prime[2] = 1;
    for (int i = 3; i < 2010; i += 2)
    {
        is_prime[i] = 1;
    }
    for (int p = 3; p * p < 2010; p += 2)
    {
        if (is_prime[p])
        {
            for (int i = p * p; i < 2010; i += p)
            {
                is_prime[i] = 0;
            }
        }
    }
    for (int p = 2; p < 2010; p++)
    {
        if (!is_prime[p])
            continue;
        for (int i = 0; i < N; i++)
        {
            int e = 0;
            while (A[i] % p == 0)
            {
                A[i] /= p;
                e++;
            }
            ord_A[i + 1] = ord_A[i] + e;
        }
        for (int i = 0; i < Q; i++)
        {
            int e = 0;
            while (P[i] % p == 0)
            {
                P[i] /= p;
                e++;
            }
            int f = ord_A[R[i]] - ord_A[L[i] - 1];
            if (f < e)
            {
                ok[i] = false;
            }
        }
    }
    for (int i = 0; i < Q; i++)
    {
        if (ok[i] and P[i] == 1)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "NO\n";
        }
    }
}
0