ARC199

ARC199

  • A:

题意:给定一个n<=10^18, 找到n=A*2^B+C,输出A+B+C

#include <iostream>
#include <cstdio>
using namespace std;
long long n,two=1,now,ans,i;
int main()
{
	scanf("%lld",&n);
	for(;two<=n;++i) two*=2;
	for(ans=n,--i,two/=2;i>=0;--i) now=i+n/two+(n-n/two*two),ans=min(ans,now),two/=2;
	cout<<ans<<'\n';
	return 0;
}
上一篇:three.js从入门到放弃(一)


下一篇:Codeforces Round #673 (Div. 1)