結果

問題 No.566 だいたい完全二分木
ユーザー motimoti
提出日時 2018-05-28 23:35:43
言語 Perl
(5.38.2)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 255 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-12 20:16:41
合計ジャッジ時間 935 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,592 KB
testcase_01 AC 2 ms
4,488 KB
testcase_02 AC 3 ms
4,536 KB
testcase_03 AC 3 ms
4,588 KB
testcase_04 AC 2 ms
4,452 KB
testcase_05 AC 3 ms
4,632 KB
testcase_06 AC 3 ms
4,612 KB
testcase_07 AC 3 ms
4,640 KB
testcase_08 AC 4 ms
4,556 KB
testcase_09 AC 4 ms
4,688 KB
testcase_10 AC 7 ms
4,876 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

my $k = <>; chomp $k;
my @res;

sub dfs {
  my ($l, $r) = @_;
  return unless $l <= $r;
  my $m = int(($l + $r) / 2);
  push @res, $m;
  dfs($l, $m - 1);
  dfs($m + 1, $r);
}

push @res, 1;
dfs(2, (2**$k) - 1);
print join(' ', @res);
0