1 solutions

  • 1
    @ 2025-10-8 16:48:58
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    int n;
    vector<int> f;
    
    signed main() {
    	cin>>n;
    	while(n>1){
    		f.push_back(n);
    		if(n%2==0)n/=2;
    		else n=n*3+1;
    	}
    	f.push_back(1);
    	reverse(f.begin(),f.end());
    	for(auto c:f){
    		cout<<c<<" ";
    	}
    	return 0;
    }
    
    
    

    Information

    ID
    1380
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    (None)
    # Submissions
    40
    Accepted
    15
    Uploaded By