Problem C
Happy Number
Time Limit
1 Second
Let the sum of the square of the digits of a positive integerS0be represented byS1.In a similar way, let the sum of the squares of the digits ofS1be represented byS2and so on. IfSi= 1 for somei1, then the original integerS0is said to be Happy number. A number, which is not happy, is calledUnhappynumber. For example 7 is a Happy number since 7 -> 49 -> 97 -> 130 -> 10 -> 1 and 4 is an Unhappy number since 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4.
Input
The input consists of several test cases, the number of which you are given in the first line of the input. Each test case consists of one line containing a single positive integerNsmaller than109.
Output
For each test case, you must print one of the following messages:
Case #p: N is aHappynumber.
Case #p: N is anUnhappynumber.
Herepstands for the case number (starting from 1). You should print the first message if the numberNis a happy number. Otherwise, print the second line.
Sample Input
Output for Sample Input
3
7
4
13
Case #1: 7 is a Happy number.
Case #2: 4 is an Unhappy number.
Case #3: 13 is a Happy number.
Problemsetter: Mohammed Shamsul Alam
International Islamic UniversityChittagong
Special thanks to Muhammad Abul Hasan
,微风吹过,海面上金光闪闪,泛起一道道美丽的浪花,