結果

問題 No.854 公平なりんご分配
ユーザー CuriousFairy315CuriousFairy315
提出日時 2019-02-22 15:48:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,592 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 73,332 KB
実行使用メモリ 41,804 KB
最終ジャッジ日時 2024-05-04 03:34:06
合計ジャッジ時間 10,886 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
13,472 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 4 ms
6,948 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 8 ms
6,944 KB
testcase_23 AC 7 ms
6,944 KB
testcase_24 AC 11 ms
9,804 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 9 ms
6,944 KB
testcase_27 AC 8 ms
6,940 KB
testcase_28 AC 7 ms
6,944 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 5 ms
6,948 KB
testcase_31 AC 7 ms
6,944 KB
testcase_32 AC 79 ms
29,952 KB
testcase_33 AC 112 ms
21,964 KB
testcase_34 AC 196 ms
39,552 KB
testcase_35 AC 131 ms
32,000 KB
testcase_36 AC 58 ms
6,940 KB
testcase_37 AC 94 ms
31,344 KB
testcase_38 AC 56 ms
23,936 KB
testcase_39 AC 348 ms
41,472 KB
testcase_40 AC 127 ms
16,256 KB
testcase_41 AC 160 ms
26,624 KB
testcase_42 AC 200 ms
41,804 KB
testcase_43 AC 230 ms
27,392 KB
testcase_44 AC 242 ms
36,352 KB
testcase_45 AC 159 ms
10,752 KB
testcase_46 AC 352 ms
35,968 KB
testcase_47 AC 101 ms
22,016 KB
testcase_48 AC 152 ms
38,272 KB
testcase_49 AC 137 ms
39,040 KB
testcase_50 AC 82 ms
28,288 KB
testcase_51 AC 335 ms
37,504 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<iostream>
#include<bitset>
using namespace std; // 575

const int MAX = 100001;
const int MAX2 = 2001;
const int PRIME = 303; // 2000までの素数

const string ERROR = "No Judge";
int main() {
	static int N, A[MAX], Q, P, L, R;
	cin >> N;
	if (!(1 <= N && N <= 100000)) {
		cout << ERROR << endl;
		return 0;
	}
	for (int i = 0;i < N;++ i) {
		cin >> A[i];
		if (!(0 <= A[i] && A[i] <= 2000)) {
			cout << ERROR << endl;
			return 0;
		}
	}
	static int prime[PRIME], sum[PRIME][MAX], sumZero[MAX];
	bitset<MAX2> sieve; // エラトステネスの篩
	for (int i = 2, j = 0;i < MAX2;++ i) {
		if (!sieve[i]) {
			prime[j++] = i;
			for (int k = i;k < MAX2;k += i) sieve[k] = true;
		}
	}
	for (int i = 0;i < PRIME;++ i) sum[0][i] = 0;
	sumZero[0] = 0;
	for (int i = 0;i < N;++ i) { // 累積和
		sumZero[i + 1] = sumZero[i] + (A[i] == 0 ? 1 : 0);
		for (int j = 0;j < PRIME;++ j) for (sum[j][i + 1] = sum[j][i];A[i] % prime[j] == 0;++ sum[j][i + 1], A[i] /= prime[j]);
	}
	// ここまでで前準備終わり、次に各クエリの処理
	cin >> Q;
	if (!(1 <= Q && Q <= 100000)) {
		cout << ERROR << endl;
		return 0;
	}
	while (Q-- > 0) {
		cin >> P >> L >> R;
		bool isDiv = sumZero[R] - sumZero[L - 1] == 0; // 割り切れるかフラグ
		for (int i = 0;i < PRIME;++ i) {
			int factor = 0;
			while (P % prime[i] == 0) {
				P /= prime[i];
				++ factor;
			}
			isDiv &= sum[i][R] - sum[i][L - 1] >= factor;
		}
		if (1 <= P && P <= 1000000000 && 1 <= L && L <= R && R <= N) cout << (isDiv && P == 1 ? "Yes" : "NO") << endl;
		else cout << ERROR << endl;
	}
	return 0;
}
0