結果

問題 No.392 2分木をたどれ
ユーザー GrayCoderGrayCoder
提出日時 2018-08-12 20:04:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 168,284 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:22:58
合計ジャッジ時間 1,815 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 8 ms
4,348 KB
testcase_02 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int M;
  cin >> M;
  int A[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }

  string ans;
  for (int i = 0; i < M; i++) {
    ans = "";
    int ai = A[i];
    while (ai > 0) {
      if (ai % 2) {
        ans += "L";
        ai = (ai * 2 + 1) / 4;
      } else {
        ans += "R";
        ai = (ai * 2 - 1) / 4;
      }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
  return 0;
}
0