結果

問題 No.854 公平なりんご分配
ユーザー tentententen
提出日時 2020-12-16 10:01:58
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,555 bytes
コンパイル時間 3,318 ms
コンパイル使用メモリ 77,340 KB
実行使用メモリ 124,904 KB
最終ジャッジ日時 2023-10-20 09:03:18
合計ジャッジ時間 26,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,540 KB
testcase_01 AC 125 ms
57,468 KB
testcase_02 AC 128 ms
57,524 KB
testcase_03 AC 116 ms
56,300 KB
testcase_04 AC 135 ms
57,496 KB
testcase_05 AC 117 ms
56,200 KB
testcase_06 AC 125 ms
57,412 KB
testcase_07 AC 128 ms
57,500 KB
testcase_08 AC 128 ms
57,540 KB
testcase_09 AC 127 ms
57,504 KB
testcase_10 AC 128 ms
57,440 KB
testcase_11 AC 129 ms
57,464 KB
testcase_12 AC 139 ms
57,664 KB
testcase_13 AC 142 ms
57,640 KB
testcase_14 AC 132 ms
57,500 KB
testcase_15 AC 132 ms
57,688 KB
testcase_16 AC 137 ms
57,560 KB
testcase_17 AC 138 ms
57,556 KB
testcase_18 AC 136 ms
57,640 KB
testcase_19 AC 138 ms
57,496 KB
testcase_20 AC 133 ms
57,340 KB
testcase_21 AC 133 ms
57,560 KB
testcase_22 AC 214 ms
60,008 KB
testcase_23 AC 211 ms
59,948 KB
testcase_24 AC 216 ms
60,376 KB
testcase_25 AC 192 ms
59,900 KB
testcase_26 AC 227 ms
60,664 KB
testcase_27 AC 203 ms
59,928 KB
testcase_28 AC 214 ms
60,136 KB
testcase_29 AC 192 ms
57,664 KB
testcase_30 AC 203 ms
60,172 KB
testcase_31 AC 213 ms
60,668 KB
testcase_32 AC 468 ms
102,900 KB
testcase_33 AC 522 ms
86,268 KB
testcase_34 AC 678 ms
120,388 KB
testcase_35 AC 566 ms
109,548 KB
testcase_36 AC 534 ms
70,888 KB
testcase_37 AC 451 ms
101,236 KB
testcase_38 AC 414 ms
89,416 KB
testcase_39 AC 843 ms
124,904 KB
testcase_40 AC 602 ms
89,008 KB
testcase_41 AC 566 ms
103,536 KB
testcase_42 AC 617 ms
119,136 KB
testcase_43 AC 705 ms
106,596 KB
testcase_44 AC 725 ms
118,372 KB
testcase_45 AC 707 ms
75,828 KB
testcase_46 AC 772 ms
119,032 KB
testcase_47 AC 502 ms
87,240 KB
testcase_48 AC 595 ms
115,540 KB
testcase_49 AC 584 ms
117,196 KB
testcase_50 AC 443 ms
96,452 KB
testcase_51 AC 786 ms
121,060 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.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][size];
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    for (int j = 0; j < size; j++) {
		        counts[i + 1][j] = counts[i][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();
		    boolean can = true;
		    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