結果

問題 No.854 公平なりんご分配
ユーザー leaf_1415leaf_1415
提出日時 2019-07-26 22:19:49
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,338 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 75,724 KB
実行使用メモリ 89,332 KB
最終ジャッジ日時 2023-09-15 01:59:10
合計ジャッジ時間 11,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,736 KB
testcase_01 AC 4 ms
6,828 KB
testcase_02 AC 4 ms
6,792 KB
testcase_03 AC 4 ms
6,720 KB
testcase_04 AC 4 ms
6,708 KB
testcase_05 AC 4 ms
6,784 KB
testcase_06 AC 4 ms
6,872 KB
testcase_07 AC 4 ms
6,732 KB
testcase_08 AC 4 ms
6,756 KB
testcase_09 AC 4 ms
6,708 KB
testcase_10 AC 4 ms
6,696 KB
testcase_11 AC 4 ms
6,840 KB
testcase_12 AC 5 ms
6,876 KB
testcase_13 AC 4 ms
6,916 KB
testcase_14 AC 4 ms
6,692 KB
testcase_15 AC 5 ms
6,760 KB
testcase_16 AC 4 ms
6,868 KB
testcase_17 AC 5 ms
6,956 KB
testcase_18 AC 4 ms
6,844 KB
testcase_19 AC 5 ms
6,908 KB
testcase_20 AC 5 ms
6,896 KB
testcase_21 AC 4 ms
6,960 KB
testcase_22 AC 9 ms
7,376 KB
testcase_23 AC 9 ms
8,204 KB
testcase_24 AC 14 ms
11,144 KB
testcase_25 AC 8 ms
7,820 KB
testcase_26 AC 14 ms
10,880 KB
testcase_27 AC 13 ms
10,904 KB
testcase_28 AC 8 ms
7,360 KB
testcase_29 AC 6 ms
7,480 KB
testcase_30 AC 8 ms
7,752 KB
testcase_31 AC 13 ms
8,616 KB
testcase_32 AC 145 ms
67,340 KB
testcase_33 AC 116 ms
39,792 KB
testcase_34 AC 237 ms
86,600 KB
testcase_35 AC 177 ms
73,536 KB
testcase_36 AC 71 ms
11,684 KB
testcase_37 AC 138 ms
65,124 KB
testcase_38 AC 111 ms
53,716 KB
testcase_39 AC 306 ms
89,332 KB
testcase_40 AC 120 ms
33,132 KB
testcase_41 AC 159 ms
59,056 KB
testcase_42 AC 220 ms
85,824 KB
testcase_43 AC 209 ms
62,268 KB
testcase_44 AC 241 ms
80,740 KB
testcase_45 AC 164 ms
20,800 KB
testcase_46 AC 279 ms
80,196 KB
testcase_47 AC 127 ms
49,184 KB
testcase_48 AC 208 ms
84,776 KB
testcase_49 AC 205 ms
85,928 KB
testcase_50 AC 133 ms
64,956 KB
testcase_51 AC 285 ms
82,396 KB
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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#define llint long long

using namespace std;

llint n, Q;
llint a[100005];
int d[325][100005];
int sum[325][100005];
map<int, int> mp;

bool prime[2005];
vector<llint> pvec;

int main(void)
{
	for(int i = 2; i < 55; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 2005; j+=i) prime[j] = true;
	}
	for(int i = 2; i < 2005; i++){
		if(!prime[i]) pvec.push_back(i);
	}
	int m = pvec.size();
	
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < m; i++){
		for(int j = 1; j <= n; j++){
			int t = a[j];
			while(t % pvec[i] == 0){
				d[i][j]++;
				t /= pvec[i];
			}
		}
		for(int j = 1; j <= n; j++){
			sum[i][j] = sum[i][j-1] + d[i][j];
		}
	}
	
	cin >> Q;
	int p, l, r;
	for(int q = 0; q < Q; q++){
		cin >> p >> l >> r;
		
		int t = p;
		mp.clear();
		for(int i = 0; i < m; i++){
			if(pvec[i] > t) break;
			while(t % pvec[i] == 0){
				mp[i]++;
				t /= pvec[i];
			}
		}
		if(t > 1){
			printf("NO\n");
			continue;
		}
		
		bool flag = true;
		for(auto it = mp.begin(); it != mp.end(); it++){
			if(it->second > sum[it->first][r]-sum[it->first][l-1]){
				flag = false;
				break;
			}
		}
		if(flag) printf("Yes\n");
		else printf("NO\n");
	}
	
	return 0;
}
0