#include <string>
static int circle = 0;
class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param n int整型
     * @return bool布尔型
     */
    bool happynum(int n) {
        // write code here

        int num = n;
        for (int i = 0; i < 9; i++) {
            string strNum = to_string(num);
            vector<int> vecNum;
            for (auto c : strNum) {
                vecNum.push_back(pow(c - '0', 2));
            }
            
            int sum = 0;
            for (auto s : vecNum) {
                cout << s << endl;
                sum += s;
                // cout << "sum " << sum << endl;
            }
            // cout << endl;
            num = sum;
            if(sum == 1) return true;
        }
        return false;
    }
};