結果

問題 No.854 公平なりんご分配
ユーザー 夜
提出日時 2021-03-26 21:02:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 621 ms / 3,153 ms
コード長 1,366 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 94,892 KB
実行使用メモリ 132,868 KB
最終ジャッジ日時 2023-08-19 06:43:19
合計ジャッジ時間 17,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 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 4 ms
4,376 KB
testcase_24 AC 6 ms
4,656 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 7 ms
4,636 KB
testcase_27 AC 5 ms
4,652 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 7 ms
4,452 KB
testcase_32 AC 67 ms
30,716 KB
testcase_33 AC 64 ms
18,068 KB
testcase_34 AC 123 ms
41,168 KB
testcase_35 AC 89 ms
33,040 KB
testcase_36 AC 50 ms
5,440 KB
testcase_37 AC 64 ms
29,040 KB
testcase_38 AC 51 ms
24,200 KB
testcase_39 AC 175 ms
43,436 KB
testcase_40 AC 71 ms
16,168 KB
testcase_41 AC 83 ms
27,096 KB
testcase_42 AC 109 ms
40,448 KB
testcase_43 AC 122 ms
28,216 KB
testcase_44 AC 133 ms
37,736 KB
testcase_45 AC 110 ms
9,940 KB
testcase_46 AC 161 ms
37,188 KB
testcase_47 AC 70 ms
22,352 KB
testcase_48 AC 101 ms
39,864 KB
testcase_49 AC 103 ms
40,672 KB
testcase_50 AC 59 ms
28,856 KB
testcase_51 AC 160 ms
39,028 KB
testcase_52 AC 124 ms
18,832 KB
testcase_53 AC 74 ms
18,748 KB
testcase_54 AC 123 ms
21,904 KB
testcase_55 AC 52 ms
18,708 KB
testcase_56 AC 43 ms
19,412 KB
testcase_57 AC 61 ms
16,340 KB
testcase_58 AC 105 ms
8,556 KB
testcase_59 AC 37 ms
14,680 KB
testcase_60 AC 85 ms
16,296 KB
testcase_61 AC 44 ms
5,912 KB
testcase_62 AC 94 ms
14,328 KB
testcase_63 AC 87 ms
14,896 KB
testcase_64 AC 29 ms
7,860 KB
testcase_65 AC 94 ms
36,076 KB
testcase_66 AC 60 ms
11,468 KB
testcase_67 AC 110 ms
24,284 KB
testcase_68 AC 104 ms
12,472 KB
testcase_69 AC 93 ms
43,840 KB
testcase_70 AC 46 ms
16,092 KB
testcase_71 AC 52 ms
17,248 KB
testcase_72 AC 68 ms
5,492 KB
testcase_73 AC 78 ms
29,576 KB
testcase_74 AC 139 ms
35,280 KB
testcase_75 AC 67 ms
17,540 KB
testcase_76 AC 120 ms
28,136 KB
testcase_77 AC 127 ms
39,688 KB
testcase_78 AC 115 ms
13,384 KB
testcase_79 AC 132 ms
24,828 KB
testcase_80 AC 119 ms
26,248 KB
testcase_81 AC 98 ms
27,188 KB
testcase_82 AC 545 ms
132,660 KB
testcase_83 AC 555 ms
132,712 KB
testcase_84 AC 556 ms
132,784 KB
testcase_85 AC 600 ms
132,736 KB
testcase_86 AC 281 ms
4,376 KB
testcase_87 AC 574 ms
132,868 KB
testcase_88 AC 621 ms
132,740 KB
testcase_89 AC 562 ms
132,712 KB
testcase_90 AC 578 ms
132,712 KB
testcase_91 AC 620 ms
132,792 KB
testcase_92 AC 562 ms
132,668 KB
testcase_93 AC 572 ms
132,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int sum[100010][330] = {};
int z[100010] = {};
vector<int> p;
int main() {
	for (int i = 2; i <= 2000; i++) {
		bool bo = true;
		for (int j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				bo = false;
			}
		}
		if (bo) {
			p.emplace_back(i);
		}
	}
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		z[i] += z[i - 1];
		if (a == 0) {
			z[i]++;
			continue;
		}
		for (int j = 0; j < p.size(); j++) {
			if (a % p[j] == 0) {
				int co = 0;
				while (a % p[j] == 0) {
					a /= p[j];
					co++;
				}
				sum[i][j] += co;
			}
			sum[i][j] += sum[i - 1][j];
		}
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, l, r;
		cin >> b >> l >> r;
		bool bo = true;
		for (int j = 0; j < p.size(); j++) {
			if (b % p[j] == 0) {
				int co = 0;
				while (b % p[j] == 0) {
					b /= p[j];
					co++;
				}
				if (sum[r][j] - sum[l - 1][j] < co) {
					bo = false;
				}
			}
		}
		if (b != 1) {
			bo = false;
		}
		if (z[r] - z[l - 1] != 0) {
			bo = true;
		}
		if (bo) {
			cout << "Yes" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}
0