結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
![]() |
提出日時 | 2025-09-16 00:30:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 568 bytes |
コンパイル時間 | 2,596 ms |
コンパイル使用メモリ | 275,576 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-16 00:30:49 |
合計ジャッジ時間 | 4,824 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; ll ans = 0; if (n % 2 == 0) { ans = (ll) m * n; } else { int cnt = 0; for (int x = 30; x >= 0; --x) { if (m & (1 << x)) { ans += (ll) (n - 1) * (1 << x); if (cnt < n) ++cnt; } else { ans += (cnt / 2 * 2) * (1 << x); } } } cout << ans << '\n'; return 0; }