結果

問題 No.854 公平なりんご分配
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-07-26 21:38:18
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 2,637 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 106,876 KB
実行使用メモリ 42,784 KB
最終ジャッジ日時 2023-09-04 01:56:19
合計ジャッジ時間 14,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 82 ms
29,916 KB
testcase_33 AC 133 ms
19,288 KB
testcase_34 AC 261 ms
39,304 KB
testcase_35 AC 168 ms
32,800 KB
testcase_36 AC 67 ms
6,168 KB
testcase_37 AC 85 ms
29,580 KB
testcase_38 AC 57 ms
22,736 KB
testcase_39 AC 476 ms
42,784 KB
testcase_40 AC 127 ms
16,948 KB
testcase_41 AC 177 ms
27,472 KB
testcase_42 AC 215 ms
39,308 KB
testcase_43 AC 331 ms
28,464 KB
testcase_44 AC 334 ms
36,604 KB
testcase_45 AC 172 ms
10,924 KB
testcase_46 AC 481 ms
36,232 KB
testcase_47 AC 124 ms
23,672 KB
testcase_48 AC 183 ms
37,976 KB
testcase_49 AC 161 ms
39,264 KB
testcase_50 AC 67 ms
27,672 KB
testcase_51 AC 441 ms
37,188 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 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");
      }
      
    }
  } catch (EOFException e) {
  }
}
0