class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @return bool布尔型
     */
    bool happynum(int n) {
        // write code here
    multiset<int>a;
    if (n==1){
        return true;
    }
else{int b=n;
while(b!=1){
    a.insert(b);
int c=0;
while(b){
int e=b%10;
c+=e*e;
b/=10;




}
b=c;
if(a.count(b)){
return false;
}





}



return true;


}



    }
};