結果
問題 |
No.47 ポケットを叩くとビスケットが2倍
|
ユーザー |
|
提出日時 | 2021-01-09 22:54:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 520 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 74,232 KB |
最終ジャッジ日時 | 2025-01-17 15:52:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 7 |
ソースコード
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <numeric> #include <optional> #include <vector> using namespace std; int main() { int32_t n; cin >> n; int32_t ans = 0; for (auto i = 0; i < 31; ++i) { if ((1 << (i + 1)) > n) { ans = i; n -= 1 << i; break; } } if (n == 0) ; else if (n == 1) ans += 1; else ans += n % 2 == 0 ? 1 : 2; cout << ans << endl; return 0; }