結果

問題 No.854 公平なりんご分配
ユーザー kwm_tkwm_t
提出日時 2023-05-01 15:30:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,014 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 207,396 KB
実行使用メモリ 241,192 KB
最終ジャッジ日時 2024-04-30 17:25:01
合計ジャッジ時間 21,433 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,940 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 3 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,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 6 ms
6,944 KB
testcase_23 AC 6 ms
6,948 KB
testcase_24 AC 10 ms
6,940 KB
testcase_25 AC 5 ms
6,944 KB
testcase_26 AC 10 ms
6,944 KB
testcase_27 AC 9 ms
6,948 KB
testcase_28 AC 6 ms
6,944 KB
testcase_29 AC 4 ms
6,944 KB
testcase_30 AC 6 ms
6,940 KB
testcase_31 AC 10 ms
6,948 KB
testcase_32 AC 102 ms
56,184 KB
testcase_33 AC 94 ms
31,396 KB
testcase_34 AC 181 ms
74,952 KB
testcase_35 AC 131 ms
60,532 KB
testcase_36 AC 68 ms
9,324 KB
testcase_37 AC 98 ms
54,980 KB
testcase_38 AC 76 ms
43,532 KB
testcase_39 AC 250 ms
79,440 KB
testcase_40 AC 101 ms
31,040 KB
testcase_41 AC 123 ms
51,004 KB
testcase_42 AC 163 ms
72,452 KB
testcase_43 AC 172 ms
51,444 KB
testcase_44 AC 191 ms
68,656 KB
testcase_45 AC 156 ms
18,288 KB
testcase_46 AC 233 ms
67,368 KB
testcase_47 AC 96 ms
39,980 KB
testcase_48 AC 155 ms
72,624 KB
testcase_49 AC 151 ms
75,092 KB
testcase_50 AC 91 ms
51,464 KB
testcase_51 AC 233 ms
72,212 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 810 ms
241,068 KB
testcase_84 AC 799 ms
241,064 KB
testcase_85 AC 861 ms
240,940 KB
testcase_86 AC 445 ms
240,940 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 827 ms
240,940 KB
testcase_93 AC 828 ms
241,068 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--;
		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 (sx[r+1][303]-sx[l][303])chk = true;
		if(chk)cout << "Yes" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}
0