結果
問題 | No.392 2分木をたどれ |
ユーザー |
![]() |
提出日時 | 2023-12-09 19:02:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 985 ms |
コンパイル使用メモリ | 106,696 KB |
最終ジャッジ日時 | 2025-02-18 09:50:15 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
コンパイルメッセージ
In file included from /usr/include/c++/13/math.h:36, from main.cpp:7: In function ‘constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up) [with _Tp = int; _Up = int]’, inlined from ‘int main()’ at main.cpp:29:18: /usr/include/c++/13/cmath:1073:17: warning: ‘n’ may be used uninitialized [-Wmaybe-uninitialized] 1073 | return pow(__type(__x), __type(__y)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:17:12: note: ‘n’ was declared here 17 | int m, n; | ^
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<cctype> #include<set> #include<bitset> #include<math.h> #include<map> #include<queue> #include<iomanip> using namespace std; using ll = long long; int main() { int m, n; cin >> m; for (int i = 0; i < m; i++){ int a; string s = ""; cin >> a; for (int j = 1; j < 13; j++){ if (a < pow(2, j) - 1) { n = j - 1; break; } } a -= (pow(2, n) -1); for (int j = 0; j < n; j++){ if ((1 << j) & a) s = "R" + s; else s = "L" +s; } cout << s << endl; } }