結果

問題 No.392 2分木をたどれ
ユーザー kpinkcatkpinkcat
提出日時 2023-12-09 19:02:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 109,264 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-09 19:02:47
合計ジャッジ時間 1,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 11 ms
6,676 KB
testcase_02 AC 11 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:27: warning: 'n' may be used uninitialized [-Wmaybe-uninitialized]
   30 |         for (int j = 0; j < n; j++){
      |                         ~~^~~
main.cpp:17:12: note: 'n' was declared here
   17 |     int m, n;
      |            ^

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;


int main()
{
    int m, n;
    cin >> m;
    for (int i = 0; i < m; i++){
        int a;
        string s = "";
        cin >> a;
        for (int j = 1; j < 13; j++){
            if (a < pow(2, j) - 1) {
                n = j - 1;
                break;
            }
        }
        a -= (pow(2, n) -1);
        for (int j = 0; j < n; j++){
            if ((1 << j) & a) s = "R" + s;
            else s = "L" +s;
        }
        cout << s << endl;
    }
}
0