結果

問題 No.129 お年玉(2)
ユーザー te-shte-sh
提出日時 2017-01-30 17:34:35
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 157,104 KB
実行使用メモリ 7,440 KB
最終ジャッジ日時 2024-06-12 06:44:10
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bigint;    // BigInt

const auto p = BigInt(10) ^^ 9;

void main()
{
  auto n = readln.chomp.to!BigInt;
  auto m = readln.chomp.to!BigInt;

  auto k = (n / 1000) % m;
  auto r1 = iota(m - k + 1, m + 1).fold!((a, b) => a * b)(BigInt(1));
  auto r2 = iota(1, k + 1).fold!((a, b) => a * b)(BigInt(1));

  writeln((r1 / r2) % p);
}
0