結果

問題 No.854 公平なりんご分配
ユーザー ahe100ahe100
提出日時 2019-07-26 22:54:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,532 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 168,540 KB
実行使用メモリ 126,960 KB
最終ジャッジ日時 2023-09-15 03:33:40
合計ジャッジ時間 21,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,856 KB
testcase_01 AC 9 ms
7,484 KB
testcase_02 AC 9 ms
7,688 KB
testcase_03 AC 10 ms
7,492 KB
testcase_04 AC 10 ms
7,572 KB
testcase_05 AC 9 ms
7,576 KB
testcase_06 AC 10 ms
7,484 KB
testcase_07 AC 10 ms
7,528 KB
testcase_08 AC 10 ms
7,688 KB
testcase_09 AC 10 ms
7,488 KB
testcase_10 AC 10 ms
7,524 KB
testcase_11 AC 10 ms
7,584 KB
testcase_12 AC 10 ms
7,588 KB
testcase_13 AC 10 ms
7,632 KB
testcase_14 AC 10 ms
7,628 KB
testcase_15 AC 10 ms
7,568 KB
testcase_16 AC 9 ms
7,572 KB
testcase_17 AC 10 ms
7,796 KB
testcase_18 AC 10 ms
7,588 KB
testcase_19 AC 10 ms
7,616 KB
testcase_20 AC 10 ms
7,756 KB
testcase_21 AC 10 ms
7,540 KB
testcase_22 AC 15 ms
7,944 KB
testcase_23 AC 13 ms
8,312 KB
testcase_24 AC 18 ms
8,592 KB
testcase_25 AC 13 ms
8,348 KB
testcase_26 AC 19 ms
8,684 KB
testcase_27 AC 14 ms
8,736 KB
testcase_28 AC 15 ms
7,884 KB
testcase_29 AC 11 ms
7,900 KB
testcase_30 AC 13 ms
7,980 KB
testcase_31 AC 19 ms
8,648 KB
testcase_32 AC 93 ms
33,864 KB
testcase_33 AC 210 ms
21,564 KB
testcase_34 AC 358 ms
44,232 KB
testcase_35 AC 218 ms
36,016 KB
testcase_36 AC 166 ms
9,200 KB
testcase_37 AC 93 ms
31,816 KB
testcase_38 AC 61 ms
27,748 KB
testcase_39 AC 696 ms
46,236 KB
testcase_40 AC 262 ms
19,436 KB
testcase_41 AC 251 ms
29,916 KB
testcase_42 AC 273 ms
42,152 KB
testcase_43 AC 496 ms
32,136 KB
testcase_44 AC 471 ms
40,324 KB
testcase_45 AC 493 ms
15,504 KB
testcase_46 AC 696 ms
40,220 KB
testcase_47 AC 185 ms
25,656 KB
testcase_48 AC 228 ms
42,208 KB
testcase_49 AC 191 ms
42,220 KB
testcase_50 AC 68 ms
31,840 KB
testcase_51 AC 664 ms
42,304 KB
testcase_52 AC 286 ms
23,588 KB
testcase_53 AC 103 ms
23,700 KB
testcase_54 AC 280 ms
25,712 KB
testcase_55 AC 48 ms
23,640 KB
testcase_56 AC 45 ms
23,688 KB
testcase_57 AC 140 ms
21,692 KB
testcase_58 AC 369 ms
13,248 KB
testcase_59 AC 47 ms
19,496 KB
testcase_60 AC 198 ms
21,492 KB
testcase_61 AC 89 ms
11,252 KB
testcase_62 AC 266 ms
19,416 KB
testcase_63 AC 115 ms
19,428 KB
testcase_64 AC 60 ms
13,240 KB
testcase_65 AC 96 ms
38,204 KB
testcase_66 AC 128 ms
15,316 KB
testcase_67 AC 168 ms
27,732 KB
testcase_68 AC 204 ms
17,476 KB
testcase_69 AC 39 ms
46,280 KB
testcase_70 AC 44 ms
19,480 KB
testcase_71 AC 53 ms
21,492 KB
testcase_72 AC 216 ms
11,188 KB
testcase_73 AC 51 ms
32,140 KB
testcase_74 AC 203 ms
37,992 KB
testcase_75 AC 138 ms
21,560 KB
testcase_76 AC 113 ms
31,868 KB
testcase_77 AC 109 ms
42,180 KB
testcase_78 AC 357 ms
17,544 KB
testcase_79 AC 232 ms
27,688 KB
testcase_80 AC 225 ms
29,824 KB
testcase_81 AC 100 ms
29,840 KB
testcase_82 AC 285 ms
126,900 KB
testcase_83 AC 692 ms
126,960 KB
testcase_84 TLE -
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;
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;

void prime_list(ll n,vector<ll>& prime_){
	ll visited[2010]={};
	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;
			}
		}
	}
}
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){
				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){
		ll tmp=1;
		if(zero[r[i]]-zero[l[i]-1]>0)tmp=0;
		for(int j=0;j<m;++j){
			if(tmp==0)break;
			tmp *= modpow(prime[j], dp[r[i]][j] - dp[l[i]-1][j], p[i]);
			tmp %= p[i];
		}
		cout<<(tmp==0?"Yes":"NO")<<endl;
	}
	return 0;
}
0