結果

問題 No.854 公平なりんご分配
ユーザー kwm_tkwm_t
提出日時 2023-05-01 15:37:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 861 ms / 3,153 ms
コード長 2,052 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 208,032 KB
実行使用メモリ 241,068 KB
最終ジャッジ日時 2024-04-30 17:29:32
合計ジャッジ時間 18,144 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 6 ms
6,944 KB
testcase_23 AC 6 ms
6,940 KB
testcase_24 AC 10 ms
9,900 KB
testcase_25 AC 5 ms
6,944 KB
testcase_26 AC 10 ms
6,940 KB
testcase_27 AC 8 ms
6,944 KB
testcase_28 AC 6 ms
6,940 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 6 ms
6,944 KB
testcase_31 AC 9 ms
6,944 KB
testcase_32 AC 103 ms
56,112 KB
testcase_33 AC 96 ms
34,632 KB
testcase_34 AC 184 ms
75,700 KB
testcase_35 AC 135 ms
59,880 KB
testcase_36 AC 68 ms
9,732 KB
testcase_37 AC 99 ms
52,252 KB
testcase_38 AC 77 ms
44,080 KB
testcase_39 AC 256 ms
80,256 KB
testcase_40 AC 105 ms
27,720 KB
testcase_41 AC 125 ms
48,424 KB
testcase_42 AC 168 ms
76,308 KB
testcase_43 AC 179 ms
51,412 KB
testcase_44 AC 196 ms
68,708 KB
testcase_45 AC 161 ms
18,428 KB
testcase_46 AC 241 ms
67,740 KB
testcase_47 AC 98 ms
39,384 KB
testcase_48 AC 158 ms
72,088 KB
testcase_49 AC 153 ms
75,592 KB
testcase_50 AC 92 ms
51,876 KB
testcase_51 AC 243 ms
71,380 KB
testcase_52 AC 127 ms
32,172 KB
testcase_53 AC 76 ms
34,820 KB
testcase_54 AC 131 ms
38,824 KB
testcase_55 AC 60 ms
35,120 KB
testcase_56 AC 61 ms
35,824 KB
testcase_57 AC 79 ms
28,008 KB
testcase_58 AC 134 ms
15,488 KB
testcase_59 AC 46 ms
26,704 KB
testcase_60 AC 95 ms
30,736 KB
testcase_61 AC 41 ms
11,276 KB
testcase_62 AC 110 ms
23,752 KB
testcase_63 AC 71 ms
26,720 KB
testcase_64 AC 34 ms
11,536 KB
testcase_65 AC 122 ms
64,544 KB
testcase_66 AC 66 ms
19,184 KB
testcase_67 AC 110 ms
43,340 KB
testcase_68 AC 92 ms
22,420 KB
testcase_69 AC 132 ms
79,964 KB
testcase_70 AC 51 ms
30,108 KB
testcase_71 AC 59 ms
32,680 KB
testcase_72 AC 88 ms
9,764 KB
testcase_73 AC 92 ms
52,628 KB
testcase_74 AC 148 ms
64,644 KB
testcase_75 AC 80 ms
31,464 KB
testcase_76 AC 106 ms
50,948 KB
testcase_77 AC 139 ms
72,600 KB
testcase_78 AC 136 ms
23,608 KB
testcase_79 AC 127 ms
46,492 KB
testcase_80 AC 126 ms
47,144 KB
testcase_81 AC 99 ms
50,828 KB
testcase_82 AC 439 ms
240,940 KB
testcase_83 AC 806 ms
240,940 KB
testcase_84 AC 795 ms
240,936 KB
testcase_85 AC 861 ms
240,944 KB
testcase_86 AC 98 ms
240,940 KB
testcase_87 AC 450 ms
240,940 KB
testcase_88 AC 451 ms
241,064 KB
testcase_89 AC 451 ms
240,944 KB
testcase_90 AC 451 ms
240,944 KB
testcase_91 AC 451 ms
241,068 KB
testcase_92 AC 855 ms
240,940 KB
testcase_93 AC 859 ms
240,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
vector<long long> sieve(long long  n = 1000000) {
	vector<bool>p(n + 1, true);
	vector<long long>ret;
	p[0] = false;
	p[1] = false;
	for (int i = 2; i <= n; ++i) {
		if (!p[i]) continue;
		ret.push_back(i);
		for (int j = 2 * i; j <= n; j += i) p[j] = false;
	}
	return ret;
}
int x[100005][304];
int sx[100005][304];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	auto plist = sieve(2000);
	rep(i, n) {
		int a; cin >> a;
		if (0 == a) {
			x[i][303] = 1;
			continue;
		}
		rep(j, plist.size()) {
		int cnt = 0;
			while (0 == a % plist[j]) {
				cnt++;
				a /= plist[j];
			}
			x[i][j] = cnt;
		}
	}
	rep(i, n) rep(j, 304)sx[i + 1][j] = sx[i][j] + x[i][j];
	int q; cin >> q;
	while (q--) {
		int p, l, r; cin >> p >> l >> r;
		l--, r--;
		if (sx[r + 1][303] - sx[l][303]) {
			cout << "Yes" << endl;
			continue;
		}
		vector<int>cnt(304);
		rep(i, plist.size()) {
			while (0 == p % plist[i]) {
				cnt[i]++;
				p /= plist[i];
			}
		}
		if (1 != p) {
			cout << "NO" << endl;
			continue;
		}
		bool chk = true;
		rep(i, 303) {
			int x = sx[r + 1][i] - sx[l][i];
			if (x < cnt[i])chk = false;
		}
		if(chk)cout << "Yes" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}
0