結果

問題 No.392 2分木をたどれ
ユーザー sotanakajimacl1
提出日時 2017-09-30 17:04:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 58,560 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 20:51:43
合計ジャッジ時間 944 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

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