結果

問題 No.289 数字を全て足そう
ユーザー piconic_X
提出日時 2015-11-10 16:55:25
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 242 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 19,564 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 23:39:48
合計ジャッジ時間 1,164 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

let char_int char =
  if char > '9' then 0
  else int_of_string (Char.escaped char)

let rec main str i sum =
    if i = String.length str then sum
    else main str (i+1) (sum + char_int str.[i])

let () = print_int (main (read_line ()) 0 0)
0