結果

問題 No.566 だいたい完全二分木
ユーザー r6ever6eve
提出日時 2017-09-08 23:56:44
言語 OCaml
(5.1.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 20,736 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-17 08:43:23
合計ジャッジ時間 1,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

let pow x n =
  let rec doit x n acc =
    if n = 0 then acc
    else doit (x * x) (n / 2) (if n mod 2 = 0 then acc else acc * x) in
  doit x n 1

let print_lst l =
  List.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) l;
  print_newline ()

let () =
  let k = read_int () in
  let n = pow 2 k - 1 in
  let l = [3; 2; 1] in
  if k = 2 then print_lst l
  else
    let rec doit i l =
      let l = i - 2 :: l @ [i - 3; i - 1; i] in
      if i = n then l
      else doit (i + 4) l in
    doit 7 l |> print_lst
0