結果

問題 No.854 公平なりんご分配
ユーザー tentententen
提出日時 2020-12-16 10:10:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,568 bytes
コンパイル時間 2,556 ms
コンパイル使用メモリ 77,976 KB
実行使用メモリ 261,872 KB
最終ジャッジ日時 2023-10-20 09:05:55
合計ジャッジ時間 60,912 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,360 KB
testcase_01 AC 132 ms
57,396 KB
testcase_02 AC 134 ms
57,560 KB
testcase_03 AC 132 ms
57,368 KB
testcase_04 AC 131 ms
57,604 KB
testcase_05 AC 131 ms
57,388 KB
testcase_06 AC 130 ms
57,460 KB
testcase_07 AC 132 ms
57,456 KB
testcase_08 AC 134 ms
57,572 KB
testcase_09 AC 133 ms
57,436 KB
testcase_10 AC 134 ms
57,456 KB
testcase_11 AC 134 ms
57,428 KB
testcase_12 AC 141 ms
57,656 KB
testcase_13 AC 141 ms
57,572 KB
testcase_14 AC 136 ms
57,464 KB
testcase_15 AC 135 ms
57,600 KB
testcase_16 AC 142 ms
57,164 KB
testcase_17 AC 144 ms
57,692 KB
testcase_18 AC 140 ms
57,632 KB
testcase_19 AC 141 ms
57,120 KB
testcase_20 AC 140 ms
57,472 KB
testcase_21 AC 138 ms
57,428 KB
testcase_22 AC 215 ms
59,872 KB
testcase_23 AC 204 ms
60,176 KB
testcase_24 AC 223 ms
60,516 KB
testcase_25 AC 186 ms
59,588 KB
testcase_26 AC 225 ms
60,468 KB
testcase_27 AC 212 ms
60,040 KB
testcase_28 AC 216 ms
60,148 KB
testcase_29 AC 189 ms
57,732 KB
testcase_30 AC 204 ms
59,948 KB
testcase_31 AC 221 ms
60,380 KB
testcase_32 AC 443 ms
97,748 KB
testcase_33 AC 515 ms
83,884 KB
testcase_34 AC 709 ms
124,656 KB
testcase_35 AC 580 ms
102,588 KB
testcase_36 AC 505 ms
71,308 KB
testcase_37 AC 437 ms
93,052 KB
testcase_38 AC 389 ms
86,496 KB
testcase_39 AC 918 ms
128,848 KB
testcase_40 AC 593 ms
85,308 KB
testcase_41 AC 598 ms
101,044 KB
testcase_42 AC 687 ms
123,404 KB
testcase_43 AC 746 ms
101,868 KB
testcase_44 AC 801 ms
122,904 KB
testcase_45 AC 869 ms
83,576 KB
testcase_46 AC 843 ms
120,824 KB
testcase_47 AC 523 ms
92,308 KB
testcase_48 AC 572 ms
117,616 KB
testcase_49 AC 600 ms
119,740 KB
testcase_50 AC 431 ms
94,136 KB
testcase_51 AC 887 ms
123,100 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 1,443 ms
259,416 KB
testcase_84 AC 1,672 ms
259,088 KB
testcase_85 AC 1,456 ms
256,204 KB
testcase_86 AC 1,157 ms
257,792 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,517 ms
261,364 KB
testcase_93 AC 1,554 ms
259,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] isNotPrime = new boolean[2000];
		int size = 0;
		for (int i = 2; i < 2000; i++) {
		    if (!isNotPrime[i]) {
		        size++;
		        for (int j = 2; j * i < 2000; j++) {
		            isNotPrime[j * i] = true;
		        }
		    }
		}
		int[] primes = new int[size];
		int idx = 0;
		for (int i = 2; i < 2000; i++) {
		    if (!isNotPrime[i]) {
		        primes[idx] = i;
		        idx++;
		    }
		}
		int[][] counts = new int[n + 1][];
		counts[0] = new int[size];
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    counts[i + 1] = (int[])counts[i].clone();
		    for (int j = 0; j < size && x > 1; j++) {
		        while (x % primes[j] == 0) {
		            counts[i + 1][j]++;
		            x /= primes[j];
		        }
		    }
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int p = sc.nextInt();
		    int left = sc.nextInt() - 1;
		    int right = sc.nextInt();
		    for (int j = 0; j < size && p > 1; j++) {
		        int limit = counts[right][j] - counts[left][j];
		        for (int k = 0; k < limit; k++) {
		            if (p % primes[j] == 0) {
		                p /= primes[j];
		            } else {
		                break;
		            }
		        }
		    }
		    if (p == 1) {
		        sb.append("Yes");
		    } else {
		        sb.append("NO");
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}
0