結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,124 KB
testcase_01 AC 4 ms
6,660 KB
testcase_02 AC 3 ms
6,716 KB
testcase_03 AC 4 ms
6,664 KB
testcase_04 AC 4 ms
6,696 KB
testcase_05 AC 4 ms
6,672 KB
testcase_06 AC 4 ms
6,732 KB
testcase_07 AC 4 ms
6,696 KB
testcase_08 AC 4 ms
6,800 KB
testcase_09 AC 4 ms
6,764 KB
testcase_10 AC 4 ms
6,708 KB
testcase_11 AC 4 ms
6,784 KB
testcase_12 AC 4 ms
6,852 KB
testcase_13 AC 4 ms
6,880 KB
testcase_14 AC 4 ms
6,656 KB
testcase_15 AC 4 ms
6,840 KB
testcase_16 AC 5 ms
6,836 KB
testcase_17 AC 4 ms
6,836 KB
testcase_18 AC 4 ms
6,808 KB
testcase_19 AC 5 ms
6,804 KB
testcase_20 AC 4 ms
6,912 KB
testcase_21 AC 5 ms
7,084 KB
testcase_22 AC 8 ms
7,376 KB
testcase_23 AC 9 ms
10,104 KB
testcase_24 AC 13 ms
10,808 KB
testcase_25 AC 8 ms
7,804 KB
testcase_26 AC 12 ms
10,864 KB
testcase_27 AC 12 ms
10,944 KB
testcase_28 AC 7 ms
7,336 KB
testcase_29 AC 6 ms
7,416 KB
testcase_30 AC 8 ms
7,752 KB
testcase_31 AC 12 ms
10,568 KB
testcase_32 AC 152 ms
67,200 KB
testcase_33 AC 131 ms
39,760 KB
testcase_34 AC 272 ms
86,312 KB
testcase_35 AC 199 ms
73,464 KB
testcase_36 AC 51 ms
11,556 KB
testcase_37 AC 145 ms
65,036 KB
testcase_38 AC 115 ms
55,276 KB
testcase_39 AC 381 ms
90,756 KB
testcase_40 AC 134 ms
35,068 KB
testcase_41 AC 184 ms
60,856 KB
testcase_42 AC 252 ms
85,624 KB
testcase_43 AC 261 ms
63,992 KB
testcase_44 AC 289 ms
80,836 KB
testcase_45 AC 143 ms
20,668 KB
testcase_46 AC 358 ms
80,372 KB
testcase_47 AC 143 ms
49,368 KB
testcase_48 AC 231 ms
84,720 KB
testcase_49 AC 222 ms
86,000 KB
testcase_50 AC 143 ms
64,816 KB
testcase_51 AC 355 ms
82,324 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)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 2; i < 2005; 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();
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> 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){
			cout << "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) cout << "Yes" << "\n";
		else cout << "NO" << "\n";
	}
	flush(cout);
	
	return 0;
}
0