結果

問題 No.854 公平なりんご分配
ユーザー ahe100ahe100
提出日時 2019-07-26 23:21:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,864 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 171,340 KB
実行使用メモリ 129,268 KB
最終ジャッジ日時 2023-09-15 04:41:27
合計ジャッジ時間 18,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
9,880 KB
testcase_01 AC 12 ms
9,880 KB
testcase_02 AC 11 ms
9,708 KB
testcase_03 AC 12 ms
9,884 KB
testcase_04 AC 12 ms
9,876 KB
testcase_05 AC 11 ms
9,840 KB
testcase_06 AC 12 ms
9,968 KB
testcase_07 AC 12 ms
9,708 KB
testcase_08 AC 12 ms
9,828 KB
testcase_09 AC 11 ms
9,700 KB
testcase_10 AC 12 ms
9,948 KB
testcase_11 AC 10 ms
9,832 KB
testcase_12 AC 11 ms
10,060 KB
testcase_13 AC 12 ms
9,928 KB
testcase_14 AC 12 ms
9,804 KB
testcase_15 AC 12 ms
9,892 KB
testcase_16 AC 12 ms
10,068 KB
testcase_17 AC 11 ms
9,940 KB
testcase_18 AC 11 ms
9,948 KB
testcase_19 AC 11 ms
9,772 KB
testcase_20 AC 11 ms
9,932 KB
testcase_21 AC 12 ms
9,960 KB
testcase_22 AC 15 ms
10,064 KB
testcase_23 AC 13 ms
10,564 KB
testcase_24 AC 16 ms
10,940 KB
testcase_25 AC 12 ms
10,244 KB
testcase_26 AC 15 ms
10,872 KB
testcase_27 AC 14 ms
11,020 KB
testcase_28 AC 14 ms
9,972 KB
testcase_29 AC 11 ms
10,160 KB
testcase_30 AC 13 ms
10,324 KB
testcase_31 AC 16 ms
10,860 KB
testcase_32 AC 41 ms
36,244 KB
testcase_33 AC 67 ms
23,900 KB
testcase_34 AC 97 ms
46,508 KB
testcase_35 AC 68 ms
38,324 KB
testcase_36 AC 78 ms
11,336 KB
testcase_37 AC 41 ms
34,040 KB
testcase_38 AC 33 ms
29,900 KB
testcase_39 AC 166 ms
48,588 KB
testcase_40 AC 82 ms
21,652 KB
testcase_41 AC 74 ms
31,976 KB
testcase_42 AC 80 ms
44,352 KB
testcase_43 AC 125 ms
34,180 KB
testcase_44 AC 117 ms
42,432 KB
testcase_45 AC 159 ms
17,648 KB
testcase_46 AC 163 ms
42,428 KB
testcase_47 AC 59 ms
28,012 KB
testcase_48 AC 72 ms
44,464 KB
testcase_49 AC 64 ms
44,480 KB
testcase_50 AC 35 ms
34,032 KB
testcase_51 AC 160 ms
44,460 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 534 ms
129,260 KB
testcase_84 AC 514 ms
129,100 KB
testcase_85 AC 560 ms
129,268 KB
testcase_86 AC 461 ms
129,212 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 527 ms
129,248 KB
testcase_93 AC 531 ms
129,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)

/*
何故かエラー出る
	解決。配列範囲には気をつけよう
倍数かどうかだけ見れば良い。
*/

int n,m,a[100010],q,p[100010];
int l[100010],r[100010],fact[2010][305],dp[100010][305],zero[100010];
vector<ll> prime,pri2;

void prime_list(ll n,vector<ll>& prime_){
	ll visited[300010]={};
	reg(i,2,n){
		if(visited[i]==0){
			prime_.push_back(i);
			reg(j,2,n){
				if(j*i>n)break;
				visited[i*j]=1;
			}
		}
	}
}
void factoring(ll n,vector<pair<ll,ll>>& v,vector<ll>& p){
	rep(i,p.size()){
		int t=0;
		while(n%p[i]==0){
			n/=p[i];
			t++;
		}
		if(t>0)v.push_back({i,t});
	}
	if(n>1)v.push_back({10000,1});
}
ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void init(){
	cin>>n;
	reg(i,1,n)cin>>a[i];
	cin>>q;
	rep(i,q)cin>>p[i]>>l[i]>>r[i];
	prime_list(2000,prime);
	m = prime.size();
	rep(j,m)fact[0][j]=0;
	reg(i,1,2000){
		ll t = i;
		rep(j,m){
			fact[i][j]=0;
			while(t%prime[j]==0){
				// if(prime[j]>=45)
				t/=prime[j];
				fact[i][j]++;
			}
		}
	}
	// 12ms
	zero[0]=0;
	rep(j,m)dp[0][j]=0;
	for(int i=1;i<=n;++i){
		zero[i]=zero[i-1];
		if(a[i]==0)zero[i]++;
		for(int j=0;j<m;++j)dp[i][j] = dp[i-1][j] + fact[a[i]][j];
	}
}

int main(void){
	init();
	for(int i=0;i<q;++i){
		bool ok=true;
		vector<pair<ll,ll>> v;
		factoring(p[i],v,prime);
		irep(j,v.size()){
			if(v[j].first>m){
				ok=false;
				break;
			}
			if(v[j].second > dp[r[i]][v[j].first] - dp[l[i]-1][v[j].first]){
				ok=false;
				break;
			}
		}
		cout<<(ok?"Yes":"NO")<<"\n";
	}
	return 0;
}
0