結果

問題 No.854 公平なりんご分配
ユーザー 37zigen37zigen
提出日時 2019-07-27 12:46:46
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,421 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 125,024 KB
最終ジャッジ日時 2023-09-15 06:14:52
合計ジャッジ時間 31,604 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
60,500 KB
testcase_01 AC 127 ms
55,932 KB
testcase_02 AC 132 ms
55,952 KB
testcase_03 AC 133 ms
55,924 KB
testcase_04 AC 131 ms
55,684 KB
testcase_05 AC 129 ms
55,840 KB
testcase_06 AC 129 ms
57,768 KB
testcase_07 AC 128 ms
55,972 KB
testcase_08 AC 128 ms
55,972 KB
testcase_09 AC 130 ms
55,700 KB
testcase_10 AC 131 ms
58,088 KB
testcase_11 AC 129 ms
56,688 KB
testcase_12 AC 142 ms
55,904 KB
testcase_13 AC 143 ms
55,780 KB
testcase_14 AC 132 ms
55,768 KB
testcase_15 AC 138 ms
56,060 KB
testcase_16 AC 143 ms
55,812 KB
testcase_17 AC 145 ms
56,124 KB
testcase_18 AC 140 ms
55,752 KB
testcase_19 AC 140 ms
55,772 KB
testcase_20 AC 136 ms
56,324 KB
testcase_21 AC 137 ms
55,860 KB
testcase_22 AC 227 ms
59,344 KB
testcase_23 AC 231 ms
59,180 KB
testcase_24 AC 267 ms
60,856 KB
testcase_25 AC 224 ms
58,584 KB
testcase_26 AC 268 ms
61,040 KB
testcase_27 AC 246 ms
60,356 KB
testcase_28 AC 230 ms
59,476 KB
testcase_29 AC 208 ms
58,696 KB
testcase_30 AC 229 ms
59,648 KB
testcase_31 AC 270 ms
60,992 KB
testcase_32 AC 583 ms
100,688 KB
testcase_33 AC 691 ms
84,900 KB
testcase_34 AC 893 ms
120,488 KB
testcase_35 AC 660 ms
104,784 KB
testcase_36 AC 759 ms
73,284 KB
testcase_37 AC 585 ms
92,980 KB
testcase_38 AC 498 ms
83,692 KB
testcase_39 AC 1,055 ms
120,868 KB
testcase_40 AC 775 ms
85,504 KB
testcase_41 AC 761 ms
103,512 KB
testcase_42 AC 841 ms
119,272 KB
testcase_43 AC 934 ms
104,748 KB
testcase_44 AC 1,048 ms
125,024 KB
testcase_45 AC 1,107 ms
78,688 KB
testcase_46 AC 1,223 ms
119,032 KB
testcase_47 AC 703 ms
91,136 KB
testcase_48 AC 825 ms
121,476 KB
testcase_49 AC 735 ms
116,324 KB
testcase_50 AC 546 ms
87,680 KB
testcase_51 AC 1,219 ms
124,688 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 #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i)
			A[i] = sc.nextInt();
		int Q = sc.nextInt();
		ArrayList<Integer> primes = new ArrayList<>();
		out: for (int i = 2; i <= 2 * 1000; ++i) {
			for (int j = 2; j * j <= i; ++j) {
				if (i % j == 0)
					continue out;
			}
			primes.add(i);
		}
		int[][] cnt = new int[N][primes.size()];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < primes.size(); ++j) {
				if (i > 0)
					cnt[i][j] = cnt[i - 1][j];
				while (A[i] % primes.get(j) == 0) {
					cnt[i][j]++;
					A[i] /= primes.get(j);
				}
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int t = 0; t < Q; ++t) {
			int P = sc.nextInt();
			int L = sc.nextInt();
			int R = sc.nextInt();
			--L;
			--R;
			boolean ok = true;
			int[] cnt2 = new int[primes.size()];
			for (int i = 0; i < primes.size(); ++i) {
				while (P % primes.get(i) == 0) {
					cnt2[i]++;
					P /= primes.get(i);
				}
				ok &= cnt[R][i] - (L > 0 ? cnt[L - 1][i] : 0) >= cnt2[i];
			}
			ok &= P == 1;
			pw.println(ok ? "Yes" : "NO");
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0