結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
|
提出日時 | 2025-09-05 23:08:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,315 bytes |
コンパイル時間 | 3,157 ms |
コンパイル使用メモリ | 275,440 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-05 23:08:25 |
合計ジャッジ時間 | 4,949 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
#include<bits/stdc++.h> #if __has_include(<atcoder/all>) #endif using namespace std; #define done(...) return pp(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define of(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(1,__VA_ARGS__);i>=i##stop;i+=i##step) #define defpp template<ostream&o=cout>void pp(const auto&...a){[[maybe_unused]]const char*c="";((o<<c<<a,c=" "),...);o<<'\n';}void epp(const auto&...a){pp<cerr>(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ namespace my{ void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);} using ll=long long; template<class T>constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} void lin(auto&...a){(cin>>...>>a);} constexpr auto even(auto x){return~x&1;} template<class T=ll>T pow2(ll n){return T(1)<<n;} constexpr ll size2(auto x){x|=1;ll r=0;while(x>0)x>>=1,++r;return r;} constexpr auto at2(auto x,auto i){return x>>i&1;} bool amin(auto&a,const auto&b){return b<a?a=b,1:0;} } namespace my{entry void main(){ LL(N,M); if(even(N))done(N*M); N=N/2*2; ll ans=0; ll free=0; of(b,size2(M)){ if(at2(M,b)){ ans+=pow2(b)*N; free++; amin(free,N); } else{ ans+=pow2(b)*(free/2*2); } } pp(ans); }}