結果

問題 No.3254 Xor, Max and Sum
ユーザー rabimea
提出日時 2025-09-25 05:44:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 2,774 ms
コンパイル使用メモリ 275,232 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-25 05:44:26
合計ジャッジ時間 5,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    ll ans = n / 2 * 2 * ll(m);
    if(n % 2 == 1 && __builtin_popcount(m) >= 2) {
        auto log2 = [](int x) {
            return 31 - __builtin_clz(x);
        };
        m -= 1 << log2(m);
        int i = log2(m);
        m -= 1 << i;
        ans += ((1 << i) - 1 - m) * 2;
    }
    cout << ans << '\n';
}
0