結果

問題 No.854 公平なりんご分配
ユーザー heno239heno239
提出日時 2019-07-26 23:12:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 625 ms / 3,153 ms
コード長 2,276 bytes
コンパイル時間 1,446 ms
コンパイル使用メモリ 115,676 KB
実行使用メモリ 129,292 KB
最終ジャッジ日時 2023-09-15 04:11:52
合計ジャッジ時間 16,261 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
8,444 KB
testcase_01 AC 8 ms
8,524 KB
testcase_02 AC 8 ms
8,528 KB
testcase_03 AC 8 ms
8,600 KB
testcase_04 AC 8 ms
8,656 KB
testcase_05 AC 8 ms
8,600 KB
testcase_06 AC 8 ms
8,584 KB
testcase_07 AC 8 ms
8,652 KB
testcase_08 AC 8 ms
8,596 KB
testcase_09 AC 8 ms
8,412 KB
testcase_10 AC 8 ms
8,468 KB
testcase_11 AC 8 ms
8,464 KB
testcase_12 AC 8 ms
8,820 KB
testcase_13 AC 8 ms
8,808 KB
testcase_14 AC 8 ms
8,676 KB
testcase_15 AC 8 ms
8,392 KB
testcase_16 AC 8 ms
8,808 KB
testcase_17 AC 8 ms
8,840 KB
testcase_18 AC 8 ms
8,796 KB
testcase_19 AC 8 ms
8,784 KB
testcase_20 AC 8 ms
9,016 KB
testcase_21 AC 8 ms
8,752 KB
testcase_22 AC 11 ms
8,964 KB
testcase_23 AC 10 ms
9,440 KB
testcase_24 AC 13 ms
9,852 KB
testcase_25 AC 10 ms
9,288 KB
testcase_26 AC 13 ms
9,920 KB
testcase_27 AC 11 ms
9,908 KB
testcase_28 AC 10 ms
9,056 KB
testcase_29 AC 9 ms
9,076 KB
testcase_30 AC 10 ms
9,220 KB
testcase_31 AC 13 ms
9,768 KB
testcase_32 AC 77 ms
34,256 KB
testcase_33 AC 77 ms
22,352 KB
testcase_34 AC 139 ms
43,916 KB
testcase_35 AC 103 ms
36,412 KB
testcase_36 AC 56 ms
10,400 KB
testcase_37 AC 74 ms
32,604 KB
testcase_38 AC 60 ms
28,092 KB
testcase_39 AC 197 ms
46,052 KB
testcase_40 AC 85 ms
20,604 KB
testcase_41 AC 97 ms
30,800 KB
testcase_42 AC 126 ms
43,200 KB
testcase_43 AC 139 ms
31,920 KB
testcase_44 AC 150 ms
40,660 KB
testcase_45 AC 136 ms
14,808 KB
testcase_46 AC 185 ms
40,272 KB
testcase_47 AC 78 ms
26,168 KB
testcase_48 AC 118 ms
42,792 KB
testcase_49 AC 113 ms
43,396 KB
testcase_50 AC 71 ms
32,568 KB
testcase_51 AC 185 ms
41,912 KB
testcase_52 AC 123 ms
23,132 KB
testcase_53 AC 73 ms
22,892 KB
testcase_54 AC 122 ms
26,032 KB
testcase_55 AC 53 ms
22,936 KB
testcase_56 AC 51 ms
23,632 KB
testcase_57 AC 70 ms
20,724 KB
testcase_58 AC 119 ms
13,600 KB
testcase_59 AC 42 ms
19,188 KB
testcase_60 AC 86 ms
20,744 KB
testcase_61 AC 42 ms
10,980 KB
testcase_62 AC 98 ms
18,776 KB
testcase_63 AC 78 ms
19,548 KB
testcase_64 AC 40 ms
12,996 KB
testcase_65 AC 93 ms
38,988 KB
testcase_66 AC 62 ms
16,352 KB
testcase_67 AC 104 ms
28,044 KB
testcase_68 AC 97 ms
16,856 KB
testcase_69 AC 99 ms
46,096 KB
testcase_70 AC 48 ms
20,492 KB
testcase_71 AC 54 ms
21,628 KB
testcase_72 AC 73 ms
10,432 KB
testcase_73 AC 77 ms
33,008 KB
testcase_74 AC 132 ms
38,476 KB
testcase_75 AC 77 ms
21,724 KB
testcase_76 AC 106 ms
31,764 KB
testcase_77 AC 121 ms
42,552 KB
testcase_78 AC 124 ms
17,816 KB
testcase_79 AC 122 ms
28,636 KB
testcase_80 AC 118 ms
29,820 KB
testcase_81 AC 93 ms
30,780 KB
testcase_82 AC 441 ms
129,112 KB
testcase_83 AC 587 ms
129,116 KB
testcase_84 AC 579 ms
129,112 KB
testcase_85 AC 499 ms
129,280 KB
testcase_86 AC 293 ms
129,292 KB
testcase_87 AC 444 ms
129,008 KB
testcase_88 AC 447 ms
129,112 KB
testcase_89 AC 444 ms
129,168 KB
testcase_90 AC 445 ms
129,020 KB
testcase_91 AC 447 ms
129,052 KB
testcase_92 AC 625 ms
129,192 KB
testcase_93 AC 619 ms
129,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

const int mn = 2001;
bool isp[mn];
vector<int> c[mn];
vector<int> p;
void init() {
	fill(isp + 2, isp + mn,true);
	for (int i = 2; i < mn; i++) {
		if (!isp[i])continue;
		p.push_back(i);
		for (int j = 2 * i; j < mn; j += i) {
			isp[j] = false;
		}
	}
	rep1(i, mn - 1) {
		c[i].resize(p.size());
		int cop = i;
		rep(j, p.size()) {
			int cnt = 0;
			while (cop%p[j] == 0) {
				cop /= p[j]; cnt++;
			}
			c[i][j] = cnt;
		}
	}
	c[0].resize(p.size(),30);
}

vec r[1 << 17];

void solve() {
	r[0].resize(p.size(), 0);
	int n, q; cin >> n;
	vector<int> zer;
	rep(i, n) {
		int a; cin >> a;
		if (a == 0) {
			zer.push_back(i);
		}
		r[i + 1] = r[i];
		rep(j, p.size()) {
			r[i + 1][j] += c[a][j];
		}
	}
	cin >> q;
	rep(i, q) {
		int a, le, ri; cin >> a >> le >> ri;
		le--; ri--;
		{
			int num = upper_bound(zer.begin(), zer.end(), ri) - lower_bound(zer.begin(), zer.end(),le);
			if (num > 0) {
				cout << "Yes" << endl; continue;
			}
		}
		rep(j, p.size()) {
			int num = r[ri + 1][j] - r[le][j];
			rep(k, num) {
				if (a%p[j])break;
				a /= p[j];
			}
		}
		if (a == 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}
0