結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
![]() |
提出日時 | 2025-09-06 13:51:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 712 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 41,784 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-06 13:51:15 |
合計ジャッジ時間 | 1,847 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3254.cc: No.3254 Xor, Max and Sum - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int BN = 30; /* typedef */ using ll = long long; /* global variables */ /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); if (n == 1) { puts("0"); return 0; } if (! (n & 1)) { printf("%lld\n", (ll)m * n); return 0; } int a0 = 0, a1 = 0; for (int i = BN - 1; i >= 0; i--) { int bi = 1 << i; if (m & bi) { if (a0 <= 0) a0 |= bi; else a1 |= bi; } else { if (a1 > 0) a0 |= bi, a1 |= bi; } } ll s = (ll)m * (n - 2) + a0 + a1; printf("%lld\n", s); return 0; }