結果

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

ソースコード

diff #

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

int main(){
  using ll=long long;
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if (n%2==0) ans=n*m;
  else if (n==1){
    cout<<0<<endl;
  }
  else{
    ans=n*(m-1);
    ll top=1;
    while (top*2<=m) top*=2;
    ll bit=1;
    ll sum=0;
    while (bit!=top){
      if (m&bit){
        ans=max(ans,m*(n-2)+(top+bit-1)+(bit+sum));
      }
      else{
        sum+=bit;
      }
      bit*=2;
    }
  }
  cout<<ans<<endl;
}
0