結果
問題 |
No.420 mod2漸化式
|
ユーザー |
|
提出日時 | 2019-01-23 11:59:07 |
言語 | Nim (2.2.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 869 bytes |
コンパイル時間 | 3,085 ms |
コンパイル使用メモリ | 60,636 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 10:33:07 |
合計ジャッジ時間 | 5,401 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 32 WA * 3 |
コンパイルメッセージ
/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]
ソースコード
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])