結果

問題 No.2853 A + B Problem
ユーザー Tatsu_mr
提出日時 2024-08-25 13:51:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 191,576 KB
最終ジャッジ日時 2025-02-24 01:00:36
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long power(long long a, long long b) {
    long long cur = a, ans = 1;
    for (int i = 0; i < 60; i++) {
        if (b & (1LL << i)) {
            ans = (ans * cur);
        }
        cur = (cur * cur);
    }
    return ans;
}

using lint = long long;

int main() {
    lint n;
    cin >> n;
    lint cnt = __builtin_popcountl(n);
    cout << (cnt < 2 ? 0 : power(2LL, cnt) - 2LL) << endl;
}
0