結果

問題 No.740 幻の木
ユーザー ichibanshiboriichibanshibori
提出日時 2018-10-09 17:41:21
言語 OCaml
(5.1.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 21,448 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:44:56
合計ジャッジ時間 819 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let solve n m p q =
  let rec solve' left_leaf cur_mon sum_mon =
    if left_leaf <= 0 then
      sum_mon
    else (
      let left_leaf' =
        if cur_mon >= p && cur_mon < p + q then
          left_leaf - m * 2
        else
          left_leaf - m
      and cur_mon' = cur_mon mod 12 + 1 in
      solve' left_leaf' cur_mon' (sum_mon + 1)
    )
  in
  solve' n 1 0

let () =
  let n, m, p, q =
    read_line ()
    |> fun l -> Scanf.sscanf l "%d %d %d %d" (fun n m p q -> (n, m, p, q))
  in
  solve n m p q
  |> string_of_int
  |> print_endline
0