結果

問題 No.392 2分木をたどれ
ユーザー vjudge1
提出日時 2025-04-18 17:31:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-18 17:31:12
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     int m;scanf("%d",&m);
      |           ~~~~~^~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
  
    int m;scanf("%d",&m);
    int x;stack<char>ans;
    for(int i=1;i<=m;++i)
    {
        scanf("%d",&x);
        while(x>2)
        {
            if(x%2==0)ans.push('R');
            else ans.push('L');
            --x;x/=2; 
            cout<<x<<endl;
        }
        if(x==1)ans.push('L');
        else ans.push('R');
        while(!ans.empty())
        {
            cout<<ans.top();
            ans.pop();
        }
        cout<<endl;
    }
    return 0;
}
0