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

京公网安备 11010502036488号