C++用vector为什么会超时啊 求解!求解!
查看原帖
C++用vector为什么会超时啊 求解!求解!
596313
Xx_Xw楼主2022/3/14 12:24
#include<iostream>
using namespace std;
#include<vector>
int main(){
	vector<int>xx;
	int n;
	cin>>n;
	while(n!=1){
	
	if(n%2==0){
		n /=2;
		xx.push_back(n);
	}else{
	
	     n=n*3+1;
	     xx.push_back(n);
	}
	} 
	/*while(!xx.empty()){
		cout<<xx.back()<<" ";
	}

	return 0;
}
2022/3/14 12:24
加载中...