結果
問題 | No.854 公平なりんご分配 |
ユーザー | 37zigen |
提出日時 | 2019-07-27 12:56:06 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 2,280 ms / 3,153 ms |
コード長 | 1,572 bytes |
コンパイル時間 | 2,291 ms |
コンパイル使用メモリ | 79,620 KB |
実行使用メモリ | 270,964 KB |
最終ジャッジ日時 | 2024-07-02 11:03:12 |
合計ジャッジ時間 | 85,015 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
41,220 KB |
testcase_01 | AC | 137 ms
41,416 KB |
testcase_02 | AC | 137 ms
41,188 KB |
testcase_03 | AC | 136 ms
41,304 KB |
testcase_04 | AC | 134 ms
41,168 KB |
testcase_05 | AC | 135 ms
41,308 KB |
testcase_06 | AC | 136 ms
41,620 KB |
testcase_07 | AC | 131 ms
41,328 KB |
testcase_08 | AC | 137 ms
41,308 KB |
testcase_09 | AC | 123 ms
40,148 KB |
testcase_10 | AC | 135 ms
41,416 KB |
testcase_11 | AC | 135 ms
41,492 KB |
testcase_12 | AC | 142 ms
41,492 KB |
testcase_13 | AC | 148 ms
41,492 KB |
testcase_14 | AC | 136 ms
41,516 KB |
testcase_15 | AC | 137 ms
41,352 KB |
testcase_16 | AC | 147 ms
41,344 KB |
testcase_17 | AC | 150 ms
41,436 KB |
testcase_18 | AC | 145 ms
41,208 KB |
testcase_19 | AC | 147 ms
41,396 KB |
testcase_20 | AC | 145 ms
41,304 KB |
testcase_21 | AC | 143 ms
41,564 KB |
testcase_22 | AC | 246 ms
45,744 KB |
testcase_23 | AC | 231 ms
44,608 KB |
testcase_24 | AC | 265 ms
47,428 KB |
testcase_25 | AC | 215 ms
44,680 KB |
testcase_26 | AC | 272 ms
48,008 KB |
testcase_27 | AC | 250 ms
47,668 KB |
testcase_28 | AC | 245 ms
45,784 KB |
testcase_29 | AC | 205 ms
42,588 KB |
testcase_30 | AC | 226 ms
44,128 KB |
testcase_31 | AC | 271 ms
47,712 KB |
testcase_32 | AC | 647 ms
85,256 KB |
testcase_33 | AC | 770 ms
75,004 KB |
testcase_34 | AC | 1,002 ms
108,680 KB |
testcase_35 | AC | 780 ms
91,572 KB |
testcase_36 | AC | 704 ms
57,996 KB |
testcase_37 | AC | 640 ms
80,756 KB |
testcase_38 | AC | 531 ms
71,696 KB |
testcase_39 | AC | 1,281 ms
119,404 KB |
testcase_40 | AC | 865 ms
76,860 KB |
testcase_41 | AC | 868 ms
92,776 KB |
testcase_42 | AC | 973 ms
108,568 KB |
testcase_43 | AC | 1,122 ms
98,176 KB |
testcase_44 | AC | 1,071 ms
107,772 KB |
testcase_45 | AC | 1,220 ms
68,396 KB |
testcase_46 | AC | 1,230 ms
104,180 KB |
testcase_47 | AC | 769 ms
81,968 KB |
testcase_48 | AC | 880 ms
105,048 KB |
testcase_49 | AC | 798 ms
107,064 KB |
testcase_50 | AC | 622 ms
79,428 KB |
testcase_51 | AC | 1,308 ms
110,504 KB |
testcase_52 | AC | 1,091 ms
85,288 KB |
testcase_53 | AC | 855 ms
77,876 KB |
testcase_54 | AC | 1,200 ms
86,812 KB |
testcase_55 | AC | 636 ms
73,124 KB |
testcase_56 | AC | 560 ms
70,988 KB |
testcase_57 | AC | 780 ms
74,632 KB |
testcase_58 | AC | 1,232 ms
67,808 KB |
testcase_59 | AC | 545 ms
62,508 KB |
testcase_60 | AC | 954 ms
74,608 KB |
testcase_61 | AC | 640 ms
59,244 KB |
testcase_62 | AC | 992 ms
71,072 KB |
testcase_63 | AC | 916 ms
73,056 KB |
testcase_64 | AC | 524 ms
60,300 KB |
testcase_65 | AC | 808 ms
97,996 KB |
testcase_66 | AC | 794 ms
68,968 KB |
testcase_67 | AC | 1,083 ms
94,388 KB |
testcase_68 | AC | 967 ms
67,756 KB |
testcase_69 | AC | 715 ms
90,696 KB |
testcase_70 | AC | 586 ms
66,524 KB |
testcase_71 | AC | 632 ms
69,324 KB |
testcase_72 | AC | 839 ms
57,944 KB |
testcase_73 | AC | 711 ms
88,332 KB |
testcase_74 | AC | 1,143 ms
102,848 KB |
testcase_75 | AC | 825 ms
75,248 KB |
testcase_76 | AC | 1,062 ms
93,968 KB |
testcase_77 | AC | 1,066 ms
112,060 KB |
testcase_78 | AC | 1,250 ms
77,500 KB |
testcase_79 | AC | 1,186 ms
89,160 KB |
testcase_80 | AC | 1,209 ms
97,784 KB |
testcase_81 | AC | 930 ms
92,672 KB |
testcase_82 | AC | 2,054 ms
259,132 KB |
testcase_83 | AC | 2,062 ms
268,920 KB |
testcase_84 | AC | 2,118 ms
268,744 KB |
testcase_85 | AC | 2,215 ms
269,364 KB |
testcase_86 | AC | 1,871 ms
268,764 KB |
testcase_87 | AC | 2,252 ms
268,748 KB |
testcase_88 | AC | 2,115 ms
270,808 KB |
testcase_89 | AC | 2,280 ms
269,032 KB |
testcase_90 | AC | 2,121 ms
270,964 KB |
testcase_91 | AC | 2,076 ms
269,036 KB |
testcase_92 | AC | 2,183 ms
268,884 KB |
testcase_93 | AC | 2,111 ms
270,336 KB |
ソースコード
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[] zero = new int[N]; int[][] cnt = new int[N][primes.size()]; for (int i = 0; i < N; ++i) { zero[i] = (i > 0 ? zero[i - 1] : 0) + (A[i] == 0 ? 1 : 0); for (int j = 0; j < primes.size(); ++j) { if (i > 0) cnt[i][j] = cnt[i - 1][j]; while (A[i] > 0 && 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; ok |= zero[R] - (L > 0 ? zero[L - 1] : 0) > 0; pw.println(ok ? "Yes" : "NO"); } pw.close(); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }