結果

問題 No.392 2分木をたどれ
ユーザー sotanakajimacl1sotanakajimacl1
提出日時 2017-09-30 17:04:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 1,224 ms
コンパイル使用メモリ 59,416 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-09 22:39:40
合計ジャッジ時間 1,201 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int m,w;

int main(){
	cin>>m;
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		int tooru[200];
		for(int i=0;i<200;i++){
			tooru[i]=0;
		}
		tooru[0]=a;
		w=1;
		while(1){
			if((a-1)%2==0){
				tooru[w]=(a-1)/2;
				a=(a-1)/2;
			}
			else {
				tooru[w]=a/2-1;
				a=a/2-1;
			}
			w++;
			if(a==0) break;
		}
		string s;
		for(int i=w-1;i>0;i--){
			if(tooru[i]*2+1==tooru[i-1]) s+='L';
			else s+='R';
		}
		cout<<s<<endl;

	}

	return 0;
}
0