結果
問題 | No.1869 Doubling? |
ユーザー |
![]() |
提出日時 | 2022-03-11 21:27:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 534 bytes |
コンパイル時間 | 2,063 ms |
コンパイル使用メモリ | 191,916 KB |
最終ジャッジ日時 | 2025-01-28 08:11:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 RE * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N, M; cin >> N >> M; bool ok = false; if (N <= 30){ if (M > (1 << N)){ ok = true; } } if (ok){ long long ans = 0; for (int i = 0; i < N; i++){ ans += 1 << i; } cout << ans << endl; } else { long long ans = 0; while (true){ if (M == 1){ ans += N; assert(N >= 1); break; } else { ans += M; M = (M + 1) / 2; N--; } } cout << ans << endl; } }