結果

問題 No.129 お年玉(2)
ユーザー diginatu
提出日時 2015-01-17 00:34:30
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 108,576 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 02:04:42
合計ジャッジ時間 2,851 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm, std.bigint;

enum MOD = 10^^9;

//return ULL nCr {(n,r)|n,r ∈ (int)}
BigInt combination(int n, int r){
  if (r == 0) return BigInt(1);
  if (r > n/2) return combination(n,n-r);
  BigInt ret=1;
  for (int i = 1; i <= r; ++i)
    ret *= (n-i+1)/i;
  return ret;
}

void main(){
  immutable N = readln().strip().to!long();
  immutable M = readln().strip().to!int();

  (M.combination(((N/1000)%M).to!int) % MOD).writeln();
}
0