結果

問題 No.854 公平なりんご分配
ユーザー CuriousFairy315CuriousFairy315
提出日時 2019-02-22 15:51:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,607 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 73,156 KB
実行使用メモリ 122,700 KB
最終ジャッジ日時 2024-05-04 03:39:32
合計ジャッジ時間 27,585 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 4 ms
6,940 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 6 ms
6,940 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 7 ms
6,944 KB
testcase_23 AC 6 ms
6,948 KB
testcase_24 AC 10 ms
6,940 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 11 ms
6,944 KB
testcase_27 AC 8 ms
6,944 KB
testcase_28 AC 7 ms
6,944 KB
testcase_29 AC 6 ms
6,944 KB
testcase_30 AC 6 ms
6,940 KB
testcase_31 AC 10 ms
6,944 KB
testcase_32 AC 98 ms
29,952 KB
testcase_33 AC 138 ms
18,176 KB
testcase_34 AC 244 ms
39,424 KB
testcase_35 AC 167 ms
32,000 KB
testcase_36 AC 67 ms
6,944 KB
testcase_37 AC 96 ms
28,288 KB
testcase_38 AC 68 ms
23,936 KB
testcase_39 AC 456 ms
41,728 KB
testcase_40 AC 158 ms
16,256 KB
testcase_41 AC 176 ms
26,752 KB
testcase_42 AC 213 ms
38,912 KB
testcase_43 AC 303 ms
27,520 KB
testcase_44 AC 303 ms
36,352 KB
testcase_45 AC 215 ms
10,752 KB
testcase_46 AC 422 ms
35,840 KB
testcase_47 AC 126 ms
22,016 KB
testcase_48 AC 188 ms
38,272 KB
testcase_49 AC 162 ms
39,168 KB
testcase_50 AC 82 ms
28,288 KB
testcase_51 AC 424 ms
37,376 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 673 ms
122,496 KB
testcase_84 AC 653 ms
122,624 KB
testcase_85 AC 686 ms
122,624 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,495 ms
122,616 KB
testcase_93 AC 1,565 ms
122,632 KB
権限があれば一括ダウンロードができます

ソースコード

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);
		if (A[i] != 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