結果

問題 No.1869 Doubling?
ユーザー ruthen71
提出日時 2022-03-11 21:52:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 171,536 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-16 02:05:21
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    V<ll> A = {M};
    ll cm = M;
    while (cm != 1) {
        cm = (cm + 1) / 2;
        A.push_back(cm);
    }
    reverse(A.begin(), A.end());
    show(A);
    if (A.size() >= N) {
        ll ans = 0;
        rep(i, N) ans += A[i];
        cout << ans << '\n';
    } else {
        ll ans = 0;
        for (auto &a : A) ans += a;
        N -= A.size();
        ans += N;
        cout << ans << '\n';
    }
    return 0;
}
0