結果

問題 No.392 2分木をたどれ
コンテスト
ユーザー vjudge1
提出日時 2025-04-18 17:32:17
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 525 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 421 ms
コンパイル使用メモリ 92,032 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2026-07-09 17:38:31
合計ジャッジ時間 1,177 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
    int m;scanf("%d",&m);
    int x;stack<char>ans;
    for(int i=1;i<=m;++i)
    {
        scanf("%d",&x);
        while(x>2)
        {
            if(x%2==0)ans.push('R');
            else ans.push('L');
            --x;x/=2; 
        }
        if(x==1)ans.push('L');
        else ans.push('R');
        while(!ans.empty())
        {
            cout<<ans.top();
            ans.pop();
        }
        cout<<endl;
    }
    return 0;
}
0