結果

問題 No.854 公平なりんご分配
ユーザー 夜
提出日時 2021-03-26 20:59:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,342 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 95,852 KB
実行使用メモリ 132,864 KB
最終ジャッジ日時 2024-05-06 13:54:37
合計ジャッジ時間 15,201 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 4 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 7 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 4 ms
5,376 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 71 ms
30,848 KB
testcase_33 AC 61 ms
18,048 KB
testcase_34 AC 119 ms
41,088 KB
testcase_35 AC 87 ms
33,152 KB
testcase_36 AC 50 ms
5,376 KB
testcase_37 AC 66 ms
29,056 KB
testcase_38 AC 52 ms
24,320 KB
testcase_39 AC 174 ms
43,520 KB
testcase_40 AC 75 ms
16,000 KB
testcase_41 AC 88 ms
27,264 KB
testcase_42 AC 121 ms
40,576 KB
testcase_43 AC 120 ms
28,288 KB
testcase_44 AC 136 ms
37,760 KB
testcase_45 AC 121 ms
10,112 KB
testcase_46 AC 165 ms
37,248 KB
testcase_47 AC 65 ms
22,272 KB
testcase_48 AC 105 ms
39,808 KB
testcase_49 AC 102 ms
40,832 KB
testcase_50 AC 63 ms
28,928 KB
testcase_51 AC 166 ms
39,040 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 571 ms
132,736 KB
testcase_84 AC 566 ms
132,736 KB
testcase_85 AC 618 ms
132,864 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 593 ms
132,736 KB
testcase_93 AC 575 ms
132,608 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 || z[r] - z[l - 1] != 0) {
			bo = false;
		}
		if (bo) {
			cout << "Yes" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}
0