[題解]CSES 1068 Weird Algorithm 發表於 2021-01-03 分類於 CSES題解 閱讀次數: Valine: 文章字數: 245 所需閱讀時間 ≈ 1 分鐘 Weird Algorithm 題目連結 12345678910111213#include <bits/stdc++.h>using namespace std;int n; signed main(){ cin>>n; while(n != 1){ cout<<n<<" "; if(n % 2 == 1)n = 3 * n + 1; else n = n/2; } cout<<1<<"\n";}