結果
問題 | No.854 公平なりんご分配 |
ユーザー |
👑 |
提出日時 | 2019-07-26 21:48:20 |
言語 | D (dmd 2.106.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,638 bytes |
コンパイル時間 | 853 ms |
コンパイル使用メモリ | 120,524 KB |
実行使用メモリ | 41,608 KB |
最終ジャッジ日時 | 2024-06-22 01:56:29 |
合計ジャッジ時間 | 9,947 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
13,756 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,944 KB |
testcase_22 | AC | 4 ms
6,944 KB |
testcase_23 | AC | 4 ms
6,944 KB |
testcase_24 | AC | 6 ms
6,940 KB |
testcase_25 | AC | 3 ms
6,944 KB |
testcase_26 | AC | 6 ms
6,944 KB |
testcase_27 | AC | 5 ms
6,944 KB |
testcase_28 | AC | 3 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 3 ms
6,940 KB |
testcase_31 | AC | 7 ms
6,944 KB |
testcase_32 | AC | 72 ms
29,240 KB |
testcase_33 | AC | 90 ms
18,560 KB |
testcase_34 | AC | 211 ms
40,704 KB |
testcase_35 | AC | 143 ms
31,728 KB |
testcase_36 | AC | 59 ms
6,940 KB |
testcase_37 | AC | 66 ms
27,936 KB |
testcase_38 | AC | 49 ms
22,604 KB |
testcase_39 | AC | 339 ms
41,608 KB |
testcase_40 | AC | 91 ms
16,516 KB |
testcase_41 | AC | 119 ms
26,952 KB |
testcase_42 | AC | 170 ms
38,776 KB |
testcase_43 | AC | 194 ms
27,212 KB |
testcase_44 | AC | 229 ms
35,708 KB |
testcase_45 | AC | 143 ms
11,468 KB |
testcase_46 | AC | 471 ms
36,276 KB |
testcase_47 | AC | 78 ms
23,476 KB |
testcase_48 | AC | 139 ms
37,692 KB |
testcase_49 | AC | 128 ms
38,944 KB |
testcase_50 | AC | 61 ms
27,316 KB |
testcase_51 | AC | 320 ms
36,612 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 | -- | - |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum LIM = 2005; int N; int[] A; int Q; int[] M, L, R; void main() { auto isnp = new bool[LIM]; foreach (p; 2 .. LIM) { if (!isnp[p]) { for (int n = 2 * p; n < LIM; n += p) { isnp[n] = true; } } } int[] primes; foreach (p; 2 .. LIM) { if (!isnp[p]) { primes ~= p; } } stderr.writeln("|primes| = ", primes.length); const primesLen = cast(int)(primes.length); try { for (; ; ) { N = readInt(); A = new int[N]; foreach (i; 0 .. N) { A[i] = readInt(); } Q = readInt(); M = new int[Q]; L = new int[Q]; R = new int[Q]; foreach (q; 0 .. Q) { M[q] = readInt(); L[q] = readInt() - 1; R[q] = readInt(); } auto sums = new int[][](primesLen, N + 1); foreach (h; 0 .. primesLen) { const p = primes[h]; foreach (i; 0 .. N) { int e; for (int a = A[i]; a % p == 0; a /= p) { ++e; } sums[h][i + 1] = sums[h][i] + e; } } foreach (q; 0 .. Q) { bool ans = true; int m = M[q]; foreach (h; 0 .. primesLen) { const p = primes[h]; int e; for (; m % p == 0; m /= p) { ++e; } ans = ans && (sums[h][R[q]] - sums[h][L[q]] >= e); } ans = ans && (m == 1); writeln(ans ? "Yes" : "NO"); } return; } } catch (EOFException e) { } }