結果
問題 | No.392 2分木をたどれ |
ユーザー |
![]() |
提出日時 | 2017-09-30 17:04:01 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 384 ms |
使用メモリ | 3,596 KB |
最終ジャッジ日時 | 2022-12-16 15:39:15 |
合計ジャッジ時間 | 1,134 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge10 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
3,380 KB |
testcase_01 | AC | 8 ms
3,596 KB |
testcase_02 | AC | 8 ms
3,500 KB |
ソースコード
#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; }