結果

問題 No.854 公平なりんご分配
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2019-07-26 22:09:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,234 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 173,980 KB
実行使用メモリ 18,472 KB
最終ジャッジ日時 2023-09-15 01:45:51
合計ジャッジ時間 12,452 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
14,536 KB
testcase_01 AC 19 ms
14,356 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 19 ms
14,364 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 19 ms
14,536 KB
testcase_10 AC 19 ms
14,408 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 19 ms
14,460 KB
testcase_15 AC 19 ms
14,400 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 19 ms
14,360 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
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 RE -
testcase_83 AC 299 ms
15,940 KB
testcase_84 WA -
testcase_85 AC 243 ms
18,472 KB
testcase_86 AC 171 ms
14,820 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
map<int, int> enumpr(int n) {
	map<int, int> V;
	for (int i = 2; 1LL * i * i <= n; i++) while (n % i == 0) V[i]++, n /= i;
	if (n > 1) V[n]++;
	return V;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/













#define yes "Yes"
#define no "NO"
int N, A[101010];
vector<int> pr[201010];
int Q;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) {
		cin >> A[i];
		if (A[i] == 1) continue;
		auto mp = enumpr(A[i]);
		fore(p, mp) rep(i, 0, p.second) pr[p.first].push_back(i);
	}
	rep(i, 0, 201010) pr[i].push_back(inf);
	cin >> Q;
	
	rep(q, 0, Q) {
		int P, L, R; cin >> P >> L >> R; L--;
		if (P == 1) {
			cout << yes << endl;
			continue;
		}
		auto mp = enumpr(P);
		bool ans = true;
		fore(p, mp) {
			auto ite1 = lower_bound(all(pr[p.first]), L);
			auto ite2 = lower_bound(all(pr[p.first]), R);
			int cnt = ite2 - ite1;
			if (cnt < p.second) {
				ans = false;
				break;
			}
		}

		if (ans) cout << yes << endl;
		else cout << no << endl;
	}
}



0