結果

問題 No.566 だいたい完全二分木
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-07 13:01:41
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 358 bytes
コンパイル時間 11,150 ms
コンパイル使用メモリ 211,620 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 19:24:23
合計ジャッジ時間 14,956 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	var k int
	_, _ = fmt.Scan(&k)
	l := int(math.Pow(2, float64(k))) - 1
	h := 3 * k

	a := ""
	for {
		s := int(math.Max(float64(l-h), 0))
		for i := s + 1; i <= l; i++ {
			a += fmt.Sprintf("%d ", i)
		}

		if l-h <= 0 {
			break
		}
		l, h = l-h, h-1
	}
	fmt.Println(strings.Trim(a, " "))
}
0