結果

問題 No.420 mod2漸化式
ユーザー むらためむらため
提出日時 2019-01-23 11:59:07
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 869 bytes
コンパイル時間 3,981 ms
コンパイル使用メモリ 66,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:32:01
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(31, 24) Warning: implicit conversion to 'cstring' from a non-const location: counts[n]; this will become a compile time error in the future [CStringConv]
/home/judge/data/code/Main.nim(31, 35) Warning: implicit conversion to 'cstring' from a non-const location: answers[n]; this will become a compile time error in the future [CStringConv]

ソースコード

diff #

import sequtils
proc combination(n,k:int):int =
  result = 1
  let x = k.max(n - k)
  let y = k.min(n - k)
  for i in 1..y: result = result * (n+1-i) div i

proc printf(formatstr: cstring){.header: "<stdio.h>", varargs.}
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 counts = (proc():seq[string] =
  var ans = newSeq[int](32)
  for n in 0..31: ans[n] = 31.combination(n)
  return ans.mapIt($it)
)()
const answers = (proc():seq[string] =
    var ans = newSeq[int](32)
    for n in 1..31:
      let k = (31-1).combination(n-1)
      for i in 0..<31: ans[n] += k * (1 shl i)
    ans[0] = 0
    return ans.mapIt($it)
)()

let n = scan()
if n >= 32 : quit "0 0",0
printf("%s %s\n",counts[n],answers[n])
0