結果
| 問題 |
No.3254 Xor, Max and Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 22:34:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| コンパイル時間 | 2,907 ms |
| コンパイル使用メモリ | 275,752 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-09-05 22:34:17 |
| 合計ジャッジ時間 | 4,293 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 23 |
ソースコード
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>;
using P = pair<int,int>;
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;}
int main() {
int n, m;
cin >> n >> m;
if (n%2 == 0) {
cout << 1LL*n*m << endl;
return 0;
}
if (n == 1) {
cout << 0 << endl;
return 0;
}
// cout << bitset<10>(m) << endl;
int l = 31-__builtin_clz(m);
if (m == (1<<l)) {
cout << 1LL*(n-1)*m << endl;
} else {
int z = 31-__builtin_clz(m-(1<<l));
ll ans = 1LL*(n-1)*m+2LL*((1<<(z+1))-1-(m-(1<<l)));
cout << ans << endl;
}
return 0;
}