結果

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

ソースコード

diff #

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

#define rep(i,n) for(int i = 0; i < n; ++i)
using ll = long long;

int main(void) {
    ll N, M;
    cin >> N >> M;
    
    if(N % 2 == 0) {
    	cout << N * M << endl;
    	return 0;
    }
    
    if(N == 1) {
    	cout << 0 << endl;
    	return 0;
    }
    
    ll cnt = 0;
    rep(i,60) {
    	if((M >> i) == 0) break;
    	if((M >> i & 1) == 0) cnt += (1LL << i);
    }
    
    cout << (N - 1) * M + cnt * 2 << endl;
    
    return 0;
}
0