結果

問題 No.854 公平なりんご分配
ユーザー leaf_1415leaf_1415
提出日時 2019-07-26 22:03:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 65,840 KB
実行使用メモリ 97,692 KB
最終ジャッジ日時 2023-09-15 01:27:27
合計ジャッジ時間 11,742 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
13,180 KB
testcase_01 AC 3 ms
4,588 KB
testcase_02 AC 3 ms
8,668 KB
testcase_03 WA -
testcase_04 AC 3 ms
8,780 KB
testcase_05 AC 3 ms
8,728 KB
testcase_06 AC 3 ms
8,700 KB
testcase_07 AC 3 ms
6,664 KB
testcase_08 AC 3 ms
8,736 KB
testcase_09 AC 3 ms
8,760 KB
testcase_10 AC 4 ms
8,776 KB
testcase_11 AC 3 ms
8,800 KB
testcase_12 AC 4 ms
10,884 KB
testcase_13 AC 4 ms
9,088 KB
testcase_14 AC 4 ms
8,756 KB
testcase_15 AC 4 ms
8,832 KB
testcase_16 AC 5 ms
10,968 KB
testcase_17 WA -
testcase_18 AC 5 ms
10,804 KB
testcase_19 AC 4 ms
10,820 KB
testcase_20 AC 4 ms
8,748 KB
testcase_21 AC 4 ms
10,804 KB
testcase_22 WA -
testcase_23 AC 11 ms
25,952 KB
testcase_24 AC 16 ms
34,412 KB
testcase_25 AC 9 ms
19,792 KB
testcase_26 AC 15 ms
24,392 KB
testcase_27 AC 13 ms
26,544 KB
testcase_28 AC 8 ms
15,224 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 151 ms
81,524 KB
testcase_33 WA -
testcase_34 AC 305 ms
94,668 KB
testcase_35 AC 218 ms
86,332 KB
testcase_36 WA -
testcase_37 AC 146 ms
80,432 KB
testcase_38 AC 114 ms
73,536 KB
testcase_39 WA -
testcase_40 AC 168 ms
58,116 KB
testcase_41 AC 206 ms
77,328 KB
testcase_42 AC 266 ms
94,200 KB
testcase_43 AC 313 ms
79,744 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 435 ms
90,808 KB
testcase_47 WA -
testcase_48 AC 246 ms
93,928 KB
testcase_49 AC 234 ms
94,400 KB
testcase_50 AC 133 ms
80,208 KB
testcase_51 AC 425 ms
91,820 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:12: warning: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Wdeprecated]
     d[i][j]++;
            ^~

ソースコード

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];
bool 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;
			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;
		}
		if(flag) cout << "Yes" << "\n";
		else cout << "NO" << "\n";
	}
	flush(cout);
	
	return 0;
}
0