結果

問題 No.854 公平なりんご分配
ユーザー ahe100ahe100
提出日時 2019-07-26 22:45:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,476 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 169,624 KB
実行使用メモリ 126,892 KB
最終ジャッジ日時 2023-09-15 03:18:14
合計ジャッジ時間 22,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,500 KB
testcase_01 AC 10 ms
7,508 KB
testcase_02 AC 10 ms
7,684 KB
testcase_03 AC 10 ms
7,540 KB
testcase_04 AC 9 ms
7,448 KB
testcase_05 AC 9 ms
7,512 KB
testcase_06 AC 9 ms
7,564 KB
testcase_07 AC 9 ms
7,552 KB
testcase_08 AC 9 ms
7,488 KB
testcase_09 AC 9 ms
7,496 KB
testcase_10 AC 9 ms
7,476 KB
testcase_11 AC 10 ms
7,596 KB
testcase_12 AC 10 ms
7,724 KB
testcase_13 AC 10 ms
7,688 KB
testcase_14 AC 10 ms
7,556 KB
testcase_15 AC 10 ms
7,492 KB
testcase_16 AC 10 ms
7,900 KB
testcase_17 AC 10 ms
7,900 KB
testcase_18 AC 9 ms
7,568 KB
testcase_19 AC 10 ms
7,552 KB
testcase_20 AC 10 ms
7,604 KB
testcase_21 AC 10 ms
7,564 KB
testcase_22 AC 16 ms
7,712 KB
testcase_23 AC 13 ms
8,248 KB
testcase_24 AC 18 ms
8,668 KB
testcase_25 AC 12 ms
8,040 KB
testcase_26 AC 19 ms
8,628 KB
testcase_27 AC 14 ms
8,648 KB
testcase_28 AC 16 ms
7,872 KB
testcase_29 AC 11 ms
8,064 KB
testcase_30 AC 13 ms
7,984 KB
testcase_31 AC 18 ms
8,512 KB
testcase_32 AC 94 ms
33,936 KB
testcase_33 AC 210 ms
21,576 KB
testcase_34 AC 356 ms
44,132 KB
testcase_35 AC 216 ms
35,892 KB
testcase_36 AC 164 ms
9,120 KB
testcase_37 AC 94 ms
31,780 KB
testcase_38 AC 61 ms
27,752 KB
testcase_39 AC 699 ms
46,248 KB
testcase_40 AC 263 ms
19,404 KB
testcase_41 AC 250 ms
29,768 KB
testcase_42 AC 276 ms
42,248 KB
testcase_43 AC 494 ms
31,800 KB
testcase_44 AC 466 ms
40,124 KB
testcase_45 AC 488 ms
15,400 KB
testcase_46 AC 697 ms
40,184 KB
testcase_47 AC 180 ms
25,632 KB
testcase_48 AC 229 ms
42,076 KB
testcase_49 AC 191 ms
42,080 KB
testcase_50 AC 69 ms
31,884 KB
testcase_51 AC 667 ms
42,164 KB
testcase_52 AC 289 ms
23,564 KB
testcase_53 AC 103 ms
23,720 KB
testcase_54 AC 280 ms
25,648 KB
testcase_55 AC 48 ms
23,668 KB
testcase_56 AC 45 ms
23,748 KB
testcase_57 AC 140 ms
21,496 KB
testcase_58 AC 365 ms
13,304 KB
testcase_59 AC 47 ms
19,728 KB
testcase_60 AC 198 ms
21,456 KB
testcase_61 AC 88 ms
11,376 KB
testcase_62 AC 266 ms
19,476 KB
testcase_63 AC 115 ms
19,736 KB
testcase_64 AC 60 ms
13,384 KB
testcase_65 AC 97 ms
38,128 KB
testcase_66 AC 129 ms
15,340 KB
testcase_67 AC 167 ms
27,696 KB
testcase_68 AC 205 ms
17,340 KB
testcase_69 AC 40 ms
46,244 KB
testcase_70 AC 44 ms
19,628 KB
testcase_71 AC 53 ms
21,664 KB
testcase_72 AC 216 ms
11,240 KB
testcase_73 AC 51 ms
31,948 KB
testcase_74 AC 205 ms
38,236 KB
testcase_75 AC 139 ms
21,472 KB
testcase_76 AC 113 ms
31,936 KB
testcase_77 AC 110 ms
42,308 KB
testcase_78 AC 356 ms
17,376 KB
testcase_79 AC 232 ms
27,656 KB
testcase_80 AC 224 ms
29,808 KB
testcase_81 AC 101 ms
29,824 KB
testcase_82 AC 292 ms
126,892 KB
testcase_83 AC 693 ms
126,836 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]++;
			}
		}
	}
	zero[0]=0;
	rep(j,m)dp[0][j]=0;
	reg(i,1,n){
		zero[i]=zero[i-1];
		if(a[i]==0)zero[i]++;
		rep(j,m)dp[i][j] = dp[i-1][j] + fact[a[i]][j];
	}
}

int main(void){
	init();
	rep(i,q){
		ll tmp=1;
		if(zero[r[i]]-zero[l[i]-1]>0)tmp=0;
		rep(j,m){
			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