結果

問題 No.3034 7 problems
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-04-01 12:35:52
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 2,448 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 106,872 KB
実行使用メモリ 9,624 KB
最終ジャッジ日時 2023-09-04 00:04:34
合計ジャッジ時間 5,294 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,532 KB
testcase_01 AC 6 ms
6,352 KB
testcase_02 AC 30 ms
7,468 KB
testcase_03 AC 13 ms
6,472 KB
testcase_04 AC 15 ms
6,996 KB
testcase_05 AC 26 ms
6,984 KB
testcase_06 AC 24 ms
9,624 KB
testcase_07 AC 24 ms
7,372 KB
testcase_08 AC 22 ms
7,580 KB
testcase_09 AC 26 ms
7,280 KB
testcase_10 AC 15 ms
6,716 KB
testcase_11 AC 23 ms
7,204 KB
testcase_12 AC 17 ms
6,992 KB
testcase_13 AC 21 ms
8,392 KB
testcase_14 AC 20 ms
6,724 KB
testcase_15 AC 20 ms
7,104 KB
testcase_16 AC 19 ms
6,680 KB
testcase_17 AC 21 ms
7,236 KB
testcase_18 AC 36 ms
8,300 KB
testcase_19 AC 22 ms
8,560 KB
testcase_20 AC 24 ms
6,984 KB
testcase_21 AC 13 ms
7,508 KB
testcase_22 AC 30 ms
8,040 KB
testcase_23 AC 20 ms
7,116 KB
testcase_24 AC 31 ms
7,380 KB
testcase_25 AC 29 ms
7,492 KB
testcase_26 AC 13 ms
6,468 KB
testcase_27 AC 36 ms
7,992 KB
testcase_28 AC 28 ms
7,172 KB
testcase_29 AC 25 ms
6,988 KB
testcase_30 AC 12 ms
7,544 KB
testcase_31 AC 28 ms
7,136 KB
testcase_32 AC 19 ms
8,296 KB
testcase_33 AC 27 ms
7,476 KB
testcase_34 AC 13 ms
6,920 KB
testcase_35 AC 28 ms
7,472 KB
testcase_36 AC 22 ms
8,264 KB
testcase_37 AC 10 ms
6,316 KB
testcase_38 AC 26 ms
7,148 KB
testcase_39 AC 26 ms
9,048 KB
testcase_40 AC 32 ms
8,984 KB
testcase_41 AC 17 ms
7,248 KB
testcase_42 AC 27 ms
7,352 KB
testcase_43 AC 37 ms
8,836 KB
testcase_44 AC 15 ms
7,508 KB
testcase_45 AC 20 ms
6,684 KB
testcase_46 AC 16 ms
6,408 KB
testcase_47 AC 15 ms
8,056 KB
testcase_48 AC 16 ms
6,468 KB
testcase_49 AC 33 ms
7,732 KB
testcase_50 AC 15 ms
6,472 KB
testcase_51 AC 16 ms
8,048 KB
testcase_52 AC 6 ms
6,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, 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 MO = 10L^^9 + 7;
enum LIM = 10^^5 + 10;

long[] inv, fac, invFac;
void prepare() {
  inv = new long[LIM];
  fac = new long[LIM];
  invFac = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - ((MO / i) * inv[cast(size_t)(MO % i)]) % MO;
  }
  fac[0] = invFac[0] = 1;
  foreach (i; 1 .. LIM) {
    fac[i] = (fac[i - 1] * i) % MO;
    invFac[i] = (invFac[i - 1] * inv[i]) % MO;
  }
}

long power(long a, long e) {
  long x = a % MO, y = 1;
  for (; e; e >>= 1) {
    if (e & 1) {
      y = (y * x) % MO;
    }
    x = (x * x) % MO;
  }
  return y;
}

void main() {
  prepare();
  
  auto sum = new long[LIM];
  foreach (i; 2 .. LIM) {
    sum[i] = (sum[i - 1] + inv[i]) % MO;
  }
  
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        if (caseId > 0) {
          writeln();
        }
        const N = readLong();
        writeln(N * N);
        writeln((N^^3 - N) * 1 + N * N);
        writeln(numCases);
        writeln(4 * N^^2 + 17);
        writeln(power(N, N^^3));
        writeln(N);
        
        // https://oeis.org/A006675
        long ans = sum[cast(size_t)(N)];
        ans *= fac[cast(size_t)(N)];
        ans %= MO;
        ans *= N;
        ans %= MO;
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}
0