結果

問題 No.741 AscNumber(Easy)
コンテスト
ユーザー むらため
提出日時 2019-01-24 12:07:20
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 588 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,855 ms
コンパイル使用メモリ 68,456 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-22 09:42:04
合計ジャッジ時間 3,183 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

const INF = 1_0000_00007
proc combination(n,k:int):int = # nCk をすばやく誤差なく計算
  result = 1
  let x = k.max(n - k)
  let y = k.min(n - k)
  var req = 1
  for i in 1..y: req *= i
  for i in 1..y:
    var m = n+1-i
    let g = m.gcd(req)
    m = m div g
    req = req div g
    result = (result * m) mod INF
let n = scan()
echo (n+9).combination(9)
0