20求解
查看原帖
20求解
374197
PAI0118楼主2023/10/18 19:48
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x=1,cnt=0;
	cin>>n;
	while(x!=n){
		if(x*2<=n){
			cnt++;
			x*=2;
		} 
		else{
			cnt++;
			x+=1;
		} 
		cout<<x<<" ";
	}
	cout<<cnt;
    return 0;
}
2023/10/18 19:48
加载中...