二十分
查看原帖
二十分
550576
far_ahead楼主2022/10/3 19:11
#include<bits/stdc++.h>
using namespace std;
int n,ans=0,x=1;
int main()
{
	//freopen("xxx.in","r"stdin);
	//freopen("xxx.out","w"stdout);
	cin>>n;
	if(n==0)
	{
		cout<<"0";
		return 0;
	}
	while(x!=n)
	{
		if(x*2>n)
		{
			x+=1;
			ans++;
		}
		else
		{
			x=x*2;
			ans++;
		}
		
	}
	cout<<ans;
    return 0;
}
2022/10/3 19:11
加载中...