public class S_202 {
public boolean isHappy(int n) {
Set<Long> set = new TreeSet<>();
while(true) {
long t = 0;
while(n > 0) {
// pow 平方
t += Math.pow(n % 10, 2);
n /= 10;
}
if(t == 1) return true;
if(!set.add(t)) return false;
n = (int) t;
}
}
}