結果
| 問題 |
No.566 だいたい完全二分木
|
| コンテスト | |
| ユーザー |
fjafjafja
|
| 提出日時 | 2017-09-10 00:12:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 611 bytes |
| コンパイル時間 | 3,473 ms |
| コンパイル使用メモリ | 77,368 KB |
| 実行使用メモリ | 54,748 KB |
| 最終ジャッジ日時 | 2024-11-07 10:21:43 |
| 合計ジャッジ時間 | 7,633 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 11 |
ソースコード
package yukicoder;
import java.util.Scanner;
public class N566 {
static int[] h;
static int K;
public static void main(String[] args)
{
Scanner sc=new Scanner (System.in);
K=sc.nextInt();
int p=(int)Math.pow(2, K);
h=new int[p-1];
h[0]=p/2;
tree(p/2,0,1);
for(int ans:h)
{
System.out.print(ans+" ");
}
}
static void tree(int p,int k,int rank)
{
h[k]=p;
//if((int)Math.pow(2, K-1)-1<=k||k<=(int)Math.pow(2,K)-2)
if(rank==K)
{
return;
}
else
{
rank++;
tree(p-(int)Math.pow(2, K-rank),2*k+1,rank);
tree(p+(int)Math.pow(2,K-rank),2*k+2,rank);
}
}
}
fjafjafja