結果
| 問題 |
No.3254 Xor, Max and Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 22:02:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 1,690 ms |
| コンパイル使用メモリ | 194,992 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-05 22:02:57 |
| 合計ジャッジ時間 | 3,163 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 |
ソースコード
#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;}
if(N == 1){cout << 0 << endl; return 0;}
long long answer = 0;
long long same = N,under = 0;
for(int i=30; i>=0; i--){
if(M&(1<<i)){
if(same > 0) same--,under++;
answer += (N/2*2)<<i;
}
else{
answer += (under/2*2)<<i;
}
}
cout << answer << endl;
}