結果

問題 No.639 An Ordinary Sequence
コンテスト
ユーザー むらため
提出日時 2019-01-27 14:42:09
言語 Nim
(2.2.12 + ACL)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 417µs
コード長 396 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,983 ms
コンパイル使用メモリ 70,092 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-10 03:53:02
合計ジャッジ時間 3,321 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import tables
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

var dp = newTable[int,int]()
dp[0] = 1
proc solve(n:int):int =
  if n in dp : return dp[n]
  result = solve(n div 3) + solve(n div 5)
  dp[n] = result

echo solve(scan())
0