結果

問題 No.854 公平なりんご分配
ユーザー ゆにぽけゆにぽけ
提出日時 2023-11-01 13:21:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,308 ms / 3,153 ms
コード長 1,276 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 129,860 KB
実行使用メモリ 122,764 KB
最終ジャッジ日時 2023-11-01 13:21:53
合計ジャッジ時間 19,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,804 KB
testcase_01 AC 4 ms
4,804 KB
testcase_02 AC 4 ms
4,804 KB
testcase_03 AC 4 ms
4,804 KB
testcase_04 AC 5 ms
4,804 KB
testcase_05 AC 4 ms
4,804 KB
testcase_06 AC 4 ms
4,804 KB
testcase_07 AC 4 ms
4,804 KB
testcase_08 AC 4 ms
4,804 KB
testcase_09 AC 4 ms
4,804 KB
testcase_10 AC 4 ms
4,804 KB
testcase_11 AC 4 ms
4,804 KB
testcase_12 AC 4 ms
4,808 KB
testcase_13 AC 4 ms
4,804 KB
testcase_14 AC 4 ms
4,804 KB
testcase_15 AC 5 ms
4,804 KB
testcase_16 AC 4 ms
4,804 KB
testcase_17 AC 4 ms
4,808 KB
testcase_18 AC 4 ms
4,804 KB
testcase_19 AC 4 ms
4,804 KB
testcase_20 AC 4 ms
4,804 KB
testcase_21 AC 4 ms
4,804 KB
testcase_22 AC 6 ms
4,812 KB
testcase_23 AC 6 ms
4,812 KB
testcase_24 AC 9 ms
6,028 KB
testcase_25 AC 5 ms
4,812 KB
testcase_26 AC 9 ms
6,028 KB
testcase_27 AC 8 ms
6,028 KB
testcase_28 AC 6 ms
4,812 KB
testcase_29 AC 5 ms
4,812 KB
testcase_30 AC 6 ms
4,812 KB
testcase_31 AC 8 ms
6,028 KB
testcase_32 AC 92 ms
29,132 KB
testcase_33 AC 112 ms
18,188 KB
testcase_34 AC 218 ms
38,860 KB
testcase_35 AC 151 ms
31,564 KB
testcase_36 AC 40 ms
6,028 KB
testcase_37 AC 93 ms
27,916 KB
testcase_38 AC 68 ms
23,052 KB
testcase_39 AC 369 ms
41,292 KB
testcase_40 AC 118 ms
15,756 KB
testcase_41 AC 171 ms
26,700 KB
testcase_42 AC 193 ms
38,860 KB
testcase_43 AC 252 ms
26,700 KB
testcase_44 AC 266 ms
36,428 KB
testcase_45 AC 120 ms
10,892 KB
testcase_46 AC 352 ms
35,212 KB
testcase_47 AC 109 ms
21,836 KB
testcase_48 AC 174 ms
37,644 KB
testcase_49 AC 157 ms
38,860 KB
testcase_50 AC 85 ms
27,916 KB
testcase_51 AC 352 ms
37,644 KB
testcase_52 AC 146 ms
18,188 KB
testcase_53 AC 75 ms
18,188 KB
testcase_54 AC 157 ms
21,836 KB
testcase_55 AC 53 ms
18,188 KB
testcase_56 AC 53 ms
19,404 KB
testcase_57 AC 76 ms
15,756 KB
testcase_58 AC 88 ms
9,676 KB
testcase_59 AC 40 ms
14,540 KB
testcase_60 AC 102 ms
15,756 KB
testcase_61 AC 24 ms
6,028 KB
testcase_62 AC 102 ms
14,540 KB
testcase_63 AC 61 ms
14,540 KB
testcase_64 AC 24 ms
8,460 KB
testcase_65 AC 109 ms
33,996 KB
testcase_66 AC 57 ms
12,108 KB
testcase_67 AC 110 ms
23,052 KB
testcase_68 AC 74 ms
12,108 KB
testcase_69 AC 102 ms
41,292 KB
testcase_70 AC 45 ms
15,756 KB
testcase_71 AC 50 ms
16,972 KB
testcase_72 AC 48 ms
6,028 KB
testcase_73 AC 76 ms
27,916 KB
testcase_74 AC 147 ms
33,996 KB
testcase_75 AC 78 ms
16,972 KB
testcase_76 AC 97 ms
26,700 KB
testcase_77 AC 121 ms
37,644 KB
testcase_78 AC 123 ms
13,324 KB
testcase_79 AC 148 ms
24,268 KB
testcase_80 AC 145 ms
25,484 KB
testcase_81 AC 96 ms
26,700 KB
testcase_82 AC 338 ms
122,764 KB
testcase_83 AC 499 ms
122,764 KB
testcase_84 AC 500 ms
122,764 KB
testcase_85 AC 529 ms
122,764 KB
testcase_86 AC 315 ms
122,764 KB
testcase_87 AC 335 ms
122,764 KB
testcase_88 AC 340 ms
122,764 KB
testcase_89 AC 336 ms
122,764 KB
testcase_90 AC 337 ms
122,764 KB
testcase_91 AC 339 ms
122,764 KB
testcase_92 AC 1,294 ms
122,764 KB
testcase_93 AC 1,308 ms
122,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
#include<functional>
#include<utility>
using namespace std;
int N,Q;
const int M = 2000;
int S[304][1 << 17];
void solve()
{
	vector<int> P;
	for(int i = 2;i <= M;i++)
	{
		bool p = true;
		for(int j = 2;j*j <= i;j++) if(i%j == 0) p = false;
		if(p) P.push_back(i);
	}
	const int L = (int)P.size();
	cin >> N;
	for(int i = 0;i < N;i++)
	{
		int A;
		cin >> A;
		S[0][i+1] = S[0][i] + (A == 0);
		for(int j = 1;j <= L;j++)
		{
			int e = 0;
			while(A != 0 && A%P[j-1] == 0) A /= P[j-1],e++;
			S[j][i+1] = S[j][i]+e;
		}
	}
	cin >> Q;
	for(;Q--;)
	{
		int x,l,r;
		cin >> x >> l >> r;
		l--;
		if(S[0][r]-S[0][l] > 0)
		{
			cout << "Yes\n";
			continue;
		}
		bool ok = true;
		for(int i = 1;i <= L;i++)
		{
			int e = 0;
			while(x%P[i-1] == 0) x /= P[i-1],e++;
			ok &= (e <= (S[i][r]-S[i][l]));
		}
		ok &= x == 1;
		cout << (ok ? "Yes\n":"NO\n");
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	/* cin >> tt; */
	while(tt--) solve();
}
0