結果

問題 No.854 公平なりんご分配
ユーザー leaf_1415leaf_1415
提出日時 2019-07-26 22:14:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,310 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 65,304 KB
実行使用メモリ 90,768 KB
最終ジャッジ日時 2023-09-15 01:54:43
合計ジャッジ時間 12,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,200 KB
testcase_01 AC 4 ms
6,820 KB
testcase_02 AC 4 ms
6,720 KB
testcase_03 AC 3 ms
6,712 KB
testcase_04 AC 4 ms
6,800 KB
testcase_05 AC 4 ms
6,692 KB
testcase_06 AC 4 ms
6,700 KB
testcase_07 AC 4 ms
6,708 KB
testcase_08 AC 4 ms
6,788 KB
testcase_09 AC 4 ms
6,868 KB
testcase_10 AC 4 ms
6,712 KB
testcase_11 AC 4 ms
6,800 KB
testcase_12 AC 4 ms
7,036 KB
testcase_13 AC 5 ms
6,868 KB
testcase_14 AC 4 ms
6,688 KB
testcase_15 AC 4 ms
6,956 KB
testcase_16 AC 5 ms
6,880 KB
testcase_17 AC 5 ms
7,004 KB
testcase_18 AC 5 ms
6,844 KB
testcase_19 AC 5 ms
6,816 KB
testcase_20 AC 5 ms
6,836 KB
testcase_21 AC 4 ms
6,836 KB
testcase_22 AC 9 ms
7,440 KB
testcase_23 AC 9 ms
8,052 KB
testcase_24 AC 15 ms
10,868 KB
testcase_25 AC 9 ms
7,824 KB
testcase_26 AC 15 ms
10,908 KB
testcase_27 AC 13 ms
10,992 KB
testcase_28 AC 9 ms
7,308 KB
testcase_29 AC 7 ms
7,488 KB
testcase_30 AC 8 ms
7,760 KB
testcase_31 AC 14 ms
10,720 KB
testcase_32 AC 165 ms
67,292 KB
testcase_33 AC 162 ms
39,788 KB
testcase_34 AC 320 ms
86,396 KB
testcase_35 AC 226 ms
73,388 KB
testcase_36 AC 79 ms
11,904 KB
testcase_37 AC 158 ms
65,048 KB
testcase_38 AC 123 ms
55,352 KB
testcase_39 AC 473 ms
90,768 KB
testcase_40 AC 174 ms
35,132 KB
testcase_41 AC 216 ms
60,784 KB
testcase_42 AC 281 ms
85,704 KB
testcase_43 AC 325 ms
63,964 KB
testcase_44 AC 352 ms
80,736 KB
testcase_45 AC 225 ms
20,680 KB
testcase_46 AC 446 ms
80,268 KB
testcase_47 AC 171 ms
49,292 KB
testcase_48 AC 263 ms
84,832 KB
testcase_49 AC 251 ms
86,012 KB
testcase_50 AC 146 ms
64,864 KB
testcase_51 AC 441 ms
82,408 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>
#define llint long long

using namespace std;

llint n, Q;
llint a[100005];
int d[325][100005];
int sum[325][100005];
int need[325];

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;
		for(int i = 0; i < m; i++) need[i] = 0;
		for(int i = 0; i < m; i++){
			if(pvec[i] > t) break;
			while(t % pvec[i] == 0){
				need[i]++;
				t /= pvec[i];
			}
		}
		if(t > 1){
			printf("NO\n");
			continue;
		}
		
		bool flag = true;
		for(int i = 0; i < m; i++){
			if(need[i] > sum[i][r]-sum[i][l-1]){
				flag = false;
				break;
			}
		}
		if(flag) printf("Yes\n");
		else printf("NO\n");
	}
	
	return 0;
}
0