結果

問題 No.854 公平なりんご分配
ユーザー chocopuuchocopuu
提出日時 2019-07-27 00:20:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,701 bytes
コンパイル時間 1,893 ms
コンパイル使用メモリ 177,496 KB
実行使用メモリ 41,544 KB
最終ジャッジ日時 2023-09-15 05:15:53
合計ジャッジ時間 11,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 64 ms
27,600 KB
testcase_38 AC 51 ms
22,896 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 92 ms
25,784 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 110 ms
37,884 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

vector<int> P;
void make_primes(int n)
{
	vector<bool> primes;
	n++;
	primes.resize(n, true);
	primes[0] = primes[1] = false;
	FOR(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++)
		primes[i * (j + 2)] = false;

	FOR(i, 2, n) if (primes[i]) P.push_back(i);
}

signed main(){
	int N;
	cin >> N;
	make_primes(2000);
	vector<int> a(N); for(auto& e:a)cin >> e;
	vector<vector<int>>cnt(N+1,vector<int>(P.size(),0));
	vector<int>zero(N+1,0);
	REP(i,N){
		if(a[i] == 0)zero[i+1]++;
		REP(j,P.size()){
			while(a[i]%P[j] == 0){
				a[i] /= P[j];
				cnt[i][j]++;
			}
		}
	}
	REP(i,N)zero[i+1] += zero[i];
	REP(i,N)REP(j,P.size())cnt[i+1][j] += cnt[i][j];
	int Q;
	cin >> Q;
	vector<int>l(Q),r(Q);
	vector<int>ans(Q);
	REP(i,Q){
		int p;
		cin >> p >> l[i] >> r[i];
		l[i]--;r[i]--;
		if(zero[r[i]+1]-zero[l[i]]){
			ans[i] = 1;continue;
		}
		vector<int>tmp(P.size(),0);
		REP(j,P.size()){
			while(p%P[j] == 0){
				p /= P[j];
				tmp[j]++;
			}
		}
		if(p != 1){
			ans[i] = 1;
			continue;
		}
		int flg = 0;
		REP(j,P.size()){
			if(tmp[j]>cnt[r[i]+1][j]-cnt[l[i]][j]){
				flg = 1;
				break;
			}
		}
		ans[i]=flg;
	}
	for(auto e:ans){
		if(e)cout<<"NO"<<endl;
		else cout<<"Yes"<<endl;
	}
}

0