結果
| 問題 |
No.642 Two Operations No.1
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-07-26 14:06:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 1,645 ms |
| コンパイル使用メモリ | 166,596 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 03:18:54 |
| 合計ジャッジ時間 | 2,276 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int n;
cin>>n;
Int l=64-__builtin_clzll(n);
if(__builtin_popcountll(n)==1){
cout<<l-1<<endl;
return 0;
}
Int x=1LL<<l;
Int ans=l+__builtin_popcountll(x-n);
cout<<ans<<endl;
return 0;
}
beet