結果

問題 No.854 公平なりんご分配
ユーザー 夜
提出日時 2021-03-26 21:02:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 652 ms / 3,153 ms
コード長 1,366 bytes
コンパイル時間 1,142 ms
コンパイル使用メモリ 96,204 KB
実行使用メモリ 132,864 KB
最終ジャッジ日時 2024-05-06 13:56:17
合計ジャッジ時間 16,554 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 AC 6 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 71 ms
30,848 KB
testcase_33 AC 68 ms
18,048 KB
testcase_34 AC 132 ms
41,088 KB
testcase_35 AC 94 ms
33,152 KB
testcase_36 AC 53 ms
5,376 KB
testcase_37 AC 68 ms
29,184 KB
testcase_38 AC 54 ms
24,192 KB
testcase_39 AC 189 ms
43,520 KB
testcase_40 AC 77 ms
16,000 KB
testcase_41 AC 90 ms
27,264 KB
testcase_42 AC 121 ms
40,576 KB
testcase_43 AC 131 ms
28,288 KB
testcase_44 AC 142 ms
37,632 KB
testcase_45 AC 124 ms
10,240 KB
testcase_46 AC 179 ms
37,376 KB
testcase_47 AC 71 ms
22,272 KB
testcase_48 AC 112 ms
39,936 KB
testcase_49 AC 107 ms
40,832 KB
testcase_50 AC 65 ms
28,928 KB
testcase_51 AC 176 ms
39,040 KB
testcase_52 AC 136 ms
18,944 KB
testcase_53 AC 81 ms
18,688 KB
testcase_54 AC 140 ms
21,888 KB
testcase_55 AC 56 ms
18,688 KB
testcase_56 AC 49 ms
19,456 KB
testcase_57 AC 69 ms
16,512 KB
testcase_58 AC 119 ms
8,704 KB
testcase_59 AC 42 ms
14,720 KB
testcase_60 AC 94 ms
16,256 KB
testcase_61 AC 48 ms
6,016 KB
testcase_62 AC 102 ms
14,336 KB
testcase_63 AC 96 ms
14,976 KB
testcase_64 AC 32 ms
7,808 KB
testcase_65 AC 94 ms
35,840 KB
testcase_66 AC 67 ms
11,648 KB
testcase_67 AC 119 ms
24,320 KB
testcase_68 AC 116 ms
12,288 KB
testcase_69 AC 96 ms
43,648 KB
testcase_70 AC 49 ms
16,128 KB
testcase_71 AC 59 ms
17,408 KB
testcase_72 AC 75 ms
5,376 KB
testcase_73 AC 81 ms
29,440 KB
testcase_74 AC 154 ms
35,328 KB
testcase_75 AC 75 ms
17,408 KB
testcase_76 AC 134 ms
28,416 KB
testcase_77 AC 140 ms
39,808 KB
testcase_78 AC 133 ms
13,312 KB
testcase_79 AC 145 ms
24,960 KB
testcase_80 AC 133 ms
25,984 KB
testcase_81 AC 110 ms
27,136 KB
testcase_82 AC 622 ms
132,736 KB
testcase_83 AC 618 ms
132,864 KB
testcase_84 AC 602 ms
132,736 KB
testcase_85 AC 638 ms
132,864 KB
testcase_86 AC 307 ms
5,376 KB
testcase_87 AC 644 ms
132,736 KB
testcase_88 AC 652 ms
132,736 KB
testcase_89 AC 642 ms
132,736 KB
testcase_90 AC 652 ms
132,736 KB
testcase_91 AC 639 ms
132,736 KB
testcase_92 AC 650 ms
132,864 KB
testcase_93 AC 650 ms
132,864 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