結果

問題 No.854 公平なりんご分配
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-07-26 21:50:12
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 2,714 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 106,952 KB
実行使用メモリ 133,908 KB
最終ジャッジ日時 2023-09-04 01:57:20
合計ジャッジ時間 26,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 6 ms
4,892 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 82 ms
29,468 KB
testcase_33 AC 97 ms
18,932 KB
testcase_34 AC 214 ms
40,564 KB
testcase_35 AC 131 ms
32,576 KB
testcase_36 AC 66 ms
6,480 KB
testcase_37 AC 80 ms
29,728 KB
testcase_38 AC 53 ms
23,204 KB
testcase_39 AC 374 ms
43,620 KB
testcase_40 AC 107 ms
17,300 KB
testcase_41 AC 128 ms
25,864 KB
testcase_42 AC 177 ms
39,252 KB
testcase_43 AC 224 ms
27,424 KB
testcase_44 AC 245 ms
36,428 KB
testcase_45 AC 161 ms
10,564 KB
testcase_46 AC 373 ms
36,944 KB
testcase_47 AC 107 ms
22,492 KB
testcase_48 AC 171 ms
37,992 KB
testcase_49 AC 162 ms
40,780 KB
testcase_50 AC 73 ms
28,428 KB
testcase_51 AC 376 ms
37,132 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 677 ms
130,232 KB
testcase_84 AC 680 ms
132,096 KB
testcase_85 AC 688 ms
132,492 KB
testcase_86 AC 522 ms
124,980 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,664 ms
130,512 KB
testcase_93 AC 1,668 ms
124,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
          if (A[i] == 0) {
            e = 32;
          } else {
            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");
      }
    }
  } catch (EOFException e) {
  }
}
0