結果

問題 No.854 公平なりんご分配
ユーザー square1001square1001
提出日時 2019-07-26 22:03:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,297 ms / 3,153 ms
コード長 1,235 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 76,956 KB
実行使用メモリ 122,696 KB
最終ジャッジ日時 2023-09-15 01:27:55
合計ジャッジ時間 21,610 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,388 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 6 ms
4,432 KB
testcase_27 AC 5 ms
4,384 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 6 ms
4,380 KB
testcase_32 AC 82 ms
28,428 KB
testcase_33 AC 93 ms
16,464 KB
testcase_34 AC 187 ms
37,836 KB
testcase_35 AC 124 ms
30,744 KB
testcase_36 AC 36 ms
4,572 KB
testcase_37 AC 79 ms
26,760 KB
testcase_38 AC 58 ms
22,260 KB
testcase_39 AC 308 ms
40,044 KB
testcase_40 AC 89 ms
14,616 KB
testcase_41 AC 120 ms
24,972 KB
testcase_42 AC 163 ms
37,420 KB
testcase_43 AC 192 ms
25,980 KB
testcase_44 AC 214 ms
34,680 KB
testcase_45 AC 91 ms
9,092 KB
testcase_46 AC 287 ms
34,140 KB
testcase_47 AC 91 ms
20,440 KB
testcase_48 AC 147 ms
36,564 KB
testcase_49 AC 133 ms
37,528 KB
testcase_50 AC 70 ms
26,496 KB
testcase_51 AC 289 ms
35,732 KB
testcase_52 AC 177 ms
17,248 KB
testcase_53 AC 96 ms
16,996 KB
testcase_54 AC 217 ms
19,932 KB
testcase_55 AC 69 ms
17,016 KB
testcase_56 AC 65 ms
17,800 KB
testcase_57 AC 82 ms
14,868 KB
testcase_58 AC 80 ms
7,768 KB
testcase_59 AC 48 ms
13,340 KB
testcase_60 AC 128 ms
14,928 KB
testcase_61 AC 32 ms
5,156 KB
testcase_62 AC 120 ms
13,120 KB
testcase_63 AC 111 ms
13,604 KB
testcase_64 AC 23 ms
7,008 KB
testcase_65 AC 114 ms
33,196 KB
testcase_66 AC 57 ms
10,392 KB
testcase_67 AC 164 ms
22,308 KB
testcase_68 AC 102 ms
11,280 KB
testcase_69 AC 99 ms
40,012 KB
testcase_70 AC 56 ms
14,720 KB
testcase_71 AC 67 ms
16,088 KB
testcase_72 AC 47 ms
4,944 KB
testcase_73 AC 106 ms
27,012 KB
testcase_74 AC 235 ms
32,404 KB
testcase_75 AC 87 ms
16,028 KB
testcase_76 AC 199 ms
25,984 KB
testcase_77 AC 205 ms
36,516 KB
testcase_78 AC 123 ms
12,092 KB
testcase_79 AC 202 ms
23,032 KB
testcase_80 AC 190 ms
23,972 KB
testcase_81 AC 155 ms
24,916 KB
testcase_82 AC 512 ms
122,580 KB
testcase_83 AC 508 ms
122,596 KB
testcase_84 AC 517 ms
122,580 KB
testcase_85 AC 327 ms
71,308 KB
testcase_86 AC 29 ms
4,380 KB
testcase_87 AC 1,281 ms
122,696 KB
testcase_88 AC 1,280 ms
122,584 KB
testcase_89 AC 1,293 ms
122,644 KB
testcase_90 AC 1,290 ms
122,644 KB
testcase_91 AC 1,297 ms
122,636 KB
testcase_92 AC 1,290 ms
122,680 KB
testcase_93 AC 1,277 ms
122,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	int mx = *max_element(A.begin(), A.end());
	vector<int> prime;
	for (int i = 2; i <= mx; ++i) {
		bool ok = true;
		for (int j = 2; j * j <= i; ++j) {
			if (i % j == 0) ok = false;
		}
		if (ok) prime.push_back(i);
	}
	vector<vector<int> > c(prime.size(), vector<int>(N + 1));
	for (int i = 0; i < N; ++i) {
		int cur = A[i];
		for (int j = 0; j < prime.size(); ++j) {
			int cnt = (A[i] == 0 ? 100 : 0);
			if (A[i] >= 1) {
				while (cur % prime[j] == 0) cur /= prime[j], ++cnt;
			}
			c[j][i + 1] = c[j][i] + cnt;
		}
	}
	vector<int> zerosum(N + 1);
	for (int i = 0; i < N; ++i) {
		zerosum[i + 1] = zerosum[i] + (A[i] == 0 ? 1 : 0);
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int P, L, R;
		cin >> P >> L >> R; --L;
		bool ok = true;
		for (int j = 0; j < prime.size(); ++j) {
			int cnt = 0;
			while (P % prime[j] == 0) P /= prime[j], ++cnt;
			if (c[j][R] - c[j][L] < cnt) ok = false;
		}
		if (P > 1) ok = false;
		cout << (ok || zerosum[R] != zerosum[L] ? "Yes\n" : "NO\n");
	}
	return 0;
}
0