結果
問題 | No.1372 Median of Submasks |
ユーザー |
![]() |
提出日時 | 2021-02-05 21:21:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 3,933 ms |
コンパイル使用メモリ | 251,544 KB |
最終ジャッジ日時 | 2025-01-18 11:51:37 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>using namespace std;#if __has_include(<atcoder/all>)#include <atcoder/all>using namespace atcoder;#endifusing ll = long long;using ld = long double;#define all(s) (s).begin(),(s).end()#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]#define rep2(i, m, n) for (int i = (m); i < (n); ++i)#define rep(i, n) rep2(i, 0, n)#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)#define drep(i, n) drep2(i, n, 0)#define rever(vec) reverse(vec.begin(), vec.end())#define sor(vec) sort(vec.begin(), vec.end())#define fi first#define se second//const ll mod = 998244353;const ll mod = 1000000007;const ll inf = 2000000000000000000ll;static const long double pi = 3.141592653589793;template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }int main() {/* mod は 1e9+7 */ios::sync_with_stdio(false);std::cin.tie(nullptr);cout<< fixed << setprecision(10);ll n;cin>>n;ll a=0;ll t=n;while(t>0){a+=t%2;t/=2;}ll ans=0;ll ti=1;while(n>0){chmax(ans,ti*(n%2));ti*=2;n/=2;}cout<<ans<<endl;}