結果

問題 No.378 名声値を稼ごう
コンテスト
ユーザー ichibanshibori
提出日時 2016-11-05 01:19:49
言語 OCaml
(5.5.0)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 147µs
コード長 368 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 92 ms
コンパイル使用メモリ 21,316 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-12 07:08:18
合計ジャッジ時間 1,502 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

let solve n =
  let rec solve' cur_n result =
    if cur_n <= 0 then result
    else
      let next_n = cur_n lsr 1
      and next_result = if cur_n land 1 = 1 then result + 1
                        else result
      in
      solve' next_n next_result
  in
  solve' n 0

let () =
  let n = read_line () |> int_of_string in
  solve n |> string_of_int |> print_endline
0