結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
|
提出日時 | 2025-09-05 22:43:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,618 bytes |
コンパイル時間 | 3,609 ms |
コンパイル使用メモリ | 275,696 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-05 22:43:43 |
合計ジャッジ時間 | 4,658 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 23 |
ソースコード
#include <bits/stdc++.h> #define int long long using namespace std; const int inf=1e18; signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m;cin>>n>>m; int ans=0; // vector<int>now,lst; // auto dfs=[&](auto dfs)->void { // if(now.size()==n){ // int xsum=0,sum=0;; // for(int i:now){ // xsum^=i; // sum+=i; // } // if(xsum==0&&sum>=ans)ans=max(ans,sum),lst=now;; // return; // } // else{ // for(int i=0;i<=m;i++){ // now.push_back(i); // dfs(dfs); // now.pop_back(); // } // } // }; // dfs(dfs); if(n%2==0){ cout<<n*m<<endl; }else{ if(n==1){ cout<<0<<endl; } else{ ans+=m*(n-2); int one=0,two=0; int tr=0; for(int i=40;i>=0;i--){ if(m&(1LL<<i)){ if(tr%2==0){ one+=(1LL<<i); ans+=(1LL<<i); } else{ two+=(1LL<<i); ans+=(1LL<<i); } tr^=1; }else{ if(one+(1LL<<i)<=m){ one+=(1LL<<i); two+=(1LL<<i); ans+=2*(1LL<<i); } } } cout<<ans<<endl; // cout<<one<<" "<<two<<endl; } } }