結果

問題 No.854 公平なりんご分配
ユーザー square1001square1001
提出日時 2019-07-26 22:02:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 75,844 KB
実行使用メモリ 122,876 KB
最終ジャッジ日時 2023-09-15 01:25:10
合計ジャッジ時間 23,752 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 6 ms
4,380 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 86 ms
28,448 KB
testcase_33 AC 103 ms
16,464 KB
testcase_34 AC 206 ms
38,032 KB
testcase_35 AC 138 ms
30,456 KB
testcase_36 AC 32 ms
4,684 KB
testcase_37 AC 83 ms
26,796 KB
testcase_38 AC 62 ms
22,464 KB
testcase_39 AC 359 ms
40,012 KB
testcase_40 AC 108 ms
14,616 KB
testcase_41 AC 141 ms
24,952 KB
testcase_42 AC 177 ms
37,308 KB
testcase_43 AC 238 ms
25,964 KB
testcase_44 AC 250 ms
34,676 KB
testcase_45 AC 92 ms
9,076 KB
testcase_46 AC 339 ms
34,200 KB
testcase_47 AC 104 ms
20,424 KB
testcase_48 AC 157 ms
36,644 KB
testcase_49 AC 145 ms
37,332 KB
testcase_50 AC 74 ms
26,488 KB
testcase_51 AC 335 ms
35,732 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 508 ms
122,692 KB
testcase_84 AC 514 ms
122,604 KB
testcase_85 AC 325 ms
71,200 KB
testcase_86 AC 30 ms
4,380 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,362 ms
122,592 KB
testcase_93 AC 1,366 ms
122,640 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;
		}
	}
	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 ? "Yes\n" : "NO\n");
	}
	return 0;
}
0