20分(3AC,其余MLE)是何原因
查看原帖
20分(3AC,其余MLE)是何原因
1373929
syy999楼主2024/7/15 10:25
#include<bits/stdc++.h>
using namespace std;
#define int long long 
stack<int> s; 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int x=n;
	while(x!=1){
		if(!x%2) s.push(x/2),x/=2; 
		else s.push(x*3+1),x=x*3+1;
	}
	cout<<1<<" ";
	while(!s.empty()){cout<<s.top()<<" ";s.pop();}
	return 0;
}
2024/7/15 10:25
加载中...