問題一覧 > 通常問題

No.392 Traverse the Binary Tree

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 292
作問者 : horiesiniti / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 1188 / 自分の提出
問題文最終更新日: 2026-06-28 13:26:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 144 (順位表) の他の問題:

Problem Statement

Binary Tree

As shown in the figure above, the nodes of a binary tree are numbered in a regular pattern starting from 0, up to 4094.
Taking node 0 as level 0, nodes 1, 2 as level 1, nodes 3, 4, 5, 6 as level 2, and so on, all nodes at level 11 are leaves, and every other node has two nodes on the level below. Traverse this tree and answer the route from node 0 to node $A_i$.
Print $L$ when going to the lower left and $R$ when going to the lower right.

Input

$m$
$A_1$
$\dots$
$A_m$

First, a number $m$ is given on one line. $0 \lt m \le 4094$
Each of the following $m$ lines contains
a single number $ 0 \lt A_i \le 4094$
Starting from node 0, print the route to reach node $A_i$, one per line. L means moving to the lower left and R means moving to the lower right.

For example, moving to 10 gives LRR

moving to 3 gives LL

moving to 13 gives RRL

and so on. For each input, output the route on one line as $Ci$.

Output

$C_1$
$\dots$
$C_m$
Print a newline at the end.

Sample

Sample 1
Input
2
21
14
Output
LRRL
RRR

Both 21 and 14 can be seen by extending the figure.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。