cswork / OA打开练习工作台

BlackrockOA #5

Happy Number

简单可在线判题

考点(AI 标注)哈希计数位运算

Given a positive integer n, repeatedly replace it with the sum of the squares of its digits. If the process reaches 1, output the happy-number marker; if it enters a cycle that does not contain 1, output the non-happy-number marker.

输入格式

A single integer n, 1≤n≤2147483647.

输出格式

Output 1 for a happy number, otherwise output 0.

样例 1

输入:

19

输出:

1

样例 2

输入:

2

输出:

0

样例 3

输入:

11

输出:

0