結果
問題 | No.392 2分木をたどれ |
ユーザー | dumsh |
提出日時 | 2016-11-19 22:13:10 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 162 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 3,683 ms |
コンパイル使用メモリ | 72,612 KB |
実行使用メモリ | 52,760 KB |
最終ジャッジ日時 | 2023-08-18 03:47:57 |
合計ジャッジ時間 | 4,690 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
49,168 KB |
testcase_01 | AC | 162 ms
52,760 KB |
testcase_02 | AC | 162 ms
52,576 KB |
ソースコード
import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); while (n > 0) { int tar = Integer.parseInt(br.readLine()); int x = 0; int h = 0; int w = 1; while (x < tar) { h++; w *= 2; x += w; } tar = tar + w - x; StringBuilder sb = new StringBuilder(); for (int i = 0; i < h; i++) { w /= 2; if (tar > w) { sb.append("R"); tar -= w; } else { sb.append("L"); } } System.out.println(sb); n--; } } }