結果

問題 No.854 公平なりんご分配
ユーザー 👑 kmjpkmjp
提出日時 2019-07-26 22:07:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 168,924 KB
実行使用メモリ 124,456 KB
最終ジャッジ日時 2023-09-15 01:37:13
合計ジャッジ時間 12,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,504 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 4 ms
4,384 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 6 ms
4,576 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 6 ms
4,812 KB
testcase_27 AC 4 ms
4,588 KB
testcase_28 AC 4 ms
4,384 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 6 ms
4,564 KB
testcase_32 AC 41 ms
29,692 KB
testcase_33 AC 53 ms
17,384 KB
testcase_34 AC 90 ms
39,960 KB
testcase_35 AC 62 ms
31,772 KB
testcase_36 AC 47 ms
5,184 KB
testcase_37 AC 40 ms
27,644 KB
testcase_38 AC 31 ms
23,576 KB
testcase_39 AC 139 ms
42,052 KB
testcase_40 AC 59 ms
15,292 KB
testcase_41 AC 63 ms
25,628 KB
testcase_42 AC 77 ms
37,916 KB
testcase_43 AC 101 ms
27,792 KB
testcase_44 AC 102 ms
35,860 KB
testcase_45 AC 108 ms
11,516 KB
testcase_46 AC 136 ms
35,888 KB
testcase_47 AC 49 ms
21,640 KB
testcase_48 AC 70 ms
37,992 KB
testcase_49 AC 65 ms
37,940 KB
testcase_50 AC 35 ms
27,652 KB
testcase_51 AC 134 ms
37,888 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 434 ms
124,196 KB
testcase_84 AC 435 ms
124,212 KB
testcase_85 AC 467 ms
124,456 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 479 ms
124,204 KB
testcase_93 AC 468 ms
124,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
int S[101010][305],Z[101010];
int Q,P,L,R;

const int prime_max = 2000;
vector<int> prime;
int NP,divp[prime_max];

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		//M[i]=NP;
		prime.push_back(i); NP++;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cprime();
	cin>>N;
	FOR(i,N) {
		cin>>x;
		FOR(j,NP) {
			S[i+1][j]=S[i][j];
			if(x) {
				while(x%prime[j]==0) {
					S[i+1][j]++;
					x/=prime[j];
				}
			}
		}
		Z[i+1]=Z[i];
		if(x==0) Z[i+1]++;
	}
	cin>>Q;
	while(Q--) {
		cin>>P>>L>>R;
		L--;
		
		if(Z[R]-Z[L]) {
			cout<<"YES"<<endl;
			continue;
		}
		
		FOR(i,NP) {
			x=0;
			while(P%prime[i]==0) {
				P/=prime[i];
				x++;
			}
			if(S[R][i]-S[L][i]<x) break;
		}
		if(i!=NP || P!=1) {
			cout<<"NO"<<endl;
		}
		else {
			cout<<"Yes"<<endl;
		}
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0