输入样例:
5
输出样例:
1:16
2:22
3:13
4:13
ACcode:
#include <bits/stdc++.h>using namespace std;int main(){int n;cin >> n;vector<int> ans;int limit = 1;ans.push_back(n);for(int i=0; i<limit; i++){//各位数字的和int sum = 0;int num = ans[i];while(num != 0){sum += num%10;num /= 10;}ans.push_back(3*sum+1);if(ans[i] != ans[i+1]){limit ++;}}for(int i=1; i<ans.size(); i++){cout << i <<":"<< ans[i] << endl;}return 0;
}