結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
|
提出日時 | 2025-09-05 21:51:35 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 4,092 ms |
コンパイル使用メモリ | 275,556 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-05 21:51:46 |
合計ジャッジ時間 | 4,656 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll =long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,M; cin>>N>>M; if(N%2==0){ cout<<N*M<<"\n"; return 0; } ll an=0; ll P=0; for(ll a=35;a>=0;a--){ if(N==0)break; if(M&(1ll<<a)){ if(P==1){ an+=(1ll<<a)*(N); P=0; N--; an+=((1ll<<a)-1)*2; } else{ an+=(1ll<<a)*(N-1); N--; P++; } } else{ } } cout<<an<<"\n"; }