結果

問題 No.419 直角三角形
ユーザー ichibanshibori
提出日時 2016-10-05 16:57:09
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 365 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 20,852 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 23:50:59
合計ジャッジ時間 1,297 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

let solve a b =
  if a = b then sqrt (a *. a +. b *. b)
  else (
    let x, y = (min a b), (max a b) in
    sqrt (y *. y -. x *. x))

let () =
  let a, b = read_line () |>
             Str.split (Str.regexp_string " ") |>
             List.map float_of_string |>
             fun lst -> (List.nth lst 0, List.nth lst 1)
  in
  solve a b |> (Printf.printf "%0.7f\n")
0