結果

問題 No.296 n度寝
ユーザー piconic_Xpiconic_X
提出日時 2015-11-07 18:03:43
言語 OCaml
(5.1.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 20,936 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:30:21
合計ジャッジ時間 921 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
File "Main.ml", lines 27-28, characters 2-97:
27 | ..match str_to_list stdin 0 ' ' [] with
28 |     [t;m;h;n] -> waketime (int_of_string n) (int_of_string h) (int_of_string m) (int_of_string t)
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
t::m::h::n::_::_

ソースコード

diff #

let main stdin =

  let rec str_to_list str i split list =
    if i > String.length str then list
    else
      let p = (try String.index_from str i split with Not_found -> String.length str) in
      let word = String.sub str i (p-i) in
      str_to_list str (p+1) split (word :: list)
  in

  let waketime n h m t =
    let minute_to_hour m =
      (m / 60) mod 24
    in

    let rec wakeminutes n' m' =
      if n' = 1 then (* h hour m minute で一回めざまし止める *)
	let hour = minute_to_hour m' in
	let minute = m' mod 60 in
	Printf.printf "%d\n%d\n" hour minute
      else
	wakeminutes (n'- 1) (m' + t)
    in
    wakeminutes n (h * 60 + m)
  in

  match str_to_list stdin 0 ' ' [] with
    [t;m;h;n] -> waketime (int_of_string n) (int_of_string h) (int_of_string m) (int_of_string t)
0