結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー むらためむらため
提出日時 2019-01-27 18:31:21
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 3,083 ms
コンパイル使用メモリ 68,872 KB
実行使用メモリ 39,572 KB
最終ジャッジ日時 2023-09-14 03:05:49
合計ジャッジ時間 7,639 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 RE -
testcase_23 AC 1 ms
4,376 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 1 ms
4,376 KB
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 1 ms
4,376 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 RE -
testcase_47 AC 2 ms
4,376 KB
testcase_48 RE -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 1 ms
4,376 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 AC 1 ms
4,376 KB
testcase_74 AC 2 ms
4,376 KB
testcase_75 AC 1 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 2 ms
4,376 KB
testcase_78 AC 1 ms
4,376 KB
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,algorithm,math,strutils
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)

const MOD = 1_000_000_007
proc combinationWithMod(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 MOD


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

let m = scan()
let H = stdin.readLine().split().map(parseInt)
if H.len == 1 :
  if H[0] == 0: quit "1",0
let n = m - (H.sum() - H.len)
let h = H.len()
let k = n - (h + h - 1)
if k < 0: quit "NA",0
if k == 0 : quit "1",0
# h箇所にk個入れる組み合わせ
echo (h+k).combinationWithMod(h)
0