#K8031. Happy Number Sequence
Happy Number Sequence
Happy Number Sequence
You are given an integer n. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. If the process ends in 1, then the number is considered Happy; otherwise, it is Unhappy.
The transformation in each step can be expressed as: \[ n \to \sum_{i=1}^{k} d_i^2 \] where \(d_i\) represents the digits of the number. In addition to determining whether the number is happy, you must output the complete sequence of numbers generated during the process.
Example:
- Input: 19
- Sequence: 19, 82, 68, 100, 1
- Output: "Happy" followed by the sequence.
inputFormat
The input consists of a single integer n provided via standard input.
Constraints: 1 ≤ n ≤ 109
outputFormat
The output should contain two lines. The first line contains either "Happy" or "Unhappy" depending on whether n is a happy number or not. The second line contains the sequence of numbers generated during the process, separated by a single space.
Note: Ensure that there are no trailing spaces.
## sample19
Happy
19 82 68 100 1
</p>