結果

問題 No.1372 Median of Submasks
ユーザー ttkkggww
提出日時 2021-02-05 21:30:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 191,168 KB
最終ジャッジ日時 2025-01-18 11:59:15
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;

ll cnt(ll x){
	ll res = 0;
	while(x){
		res += x&1;
		x/=2;
	}
	return res;
}

int main(){
	ll n;
	cin >> n;
	if(cnt(n)==1){
		cout<<n<<endl;
	}
	else{
		for(ll i = 0;;i++){
			if(n>>i&1LL){
				n -= 1LL<<i;
				cout<<n<<endl;
				return 0;
			}
		}
	}

}
0