結果

問題 No.3254 Xor, Max and Sum
ユーザー GOTKAKO
提出日時 2025-09-05 21:34:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 194,880 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-05 21:34:48
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    long long N,M; cin >> N >> M;
    if(N%2 == 0){cout << N*M << endl; return 0;}
    long long answer = N/2*2*M,now = (N-2)*M;
    for(int i=30; i>=0; i--) if(M&(1<<i)){
        int mask = (1<<i)-1;
        now += (1LL<<i)+(mask&(~M));
        now += mask;
        break;
    }
    cout << max(answer,now) << endl;
}
0