結果

問題 No.566 だいたい完全二分木
ユーザー ひゅーらひゅーら
提出日時 2017-09-08 23:03:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 65,224 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 20:55:47
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge5 / 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d", &k);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

int k;

void solve(int min, int max){
	if(min + 1 == max){
		printf("%d %d ", min, max);
		return;
	}else if(min >= max){
		printf("%d ", min);
		return;
	}
	int mid = (max+min)/2;
	printf("%d ", mid);
	solve(min, mid-1);
	solve(mid+1, max);
	return;
}

int main(){
	scanf("%d", &k);
	int max = pow(2, k) - 1;
	solve(1, max);
	printf("\n");
	return 0;
}
0