結果
問題 | No.392 2分木をたどれ |
ユーザー |
![]() |
提出日時 | 2018-09-19 14:48:12 |
言語 | Java17 (openjdk 17.0.1) |
結果 |
AC
|
実行時間 | 286 ms / 2,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 1,834 ms |
使用メモリ | 44,568 KB |
最終ジャッジ日時 | 2023-02-16 03:23:22 |
合計ジャッジ時間 | 3,437 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
37,192 KB |
testcase_01 | AC | 273 ms
44,036 KB |
testcase_02 | AC | 286 ms
44,568 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int m = scan.nextInt(); int[]A = new int[m]; for(int i = 0; i < m; i++) { A[i] = scan.nextInt(); } scan.close(); StringBuilder[] sb = new StringBuilder[m]; for(int i = 0; i < m; i++) { int t = A[i]; sb[i] = new StringBuilder(); while(t != 0) { if(t % 2 == 0) { sb[i].append("R"); t = t / 2 - 1; }else { sb[i].append("L"); t = t / 2; } } } for(int i = 0; i < m; i++) { System.out.println(sb[i].reverse().toString()); } } }