#K7426. Detect Cycle in Sum of Squares Sequence

    ID: 34158 Type: Default 1000ms 256MiB

Detect Cycle in Sum of Squares Sequence

Detect Cycle in Sum of Squares Sequence

You are given a positive integer \(n\). Define a transformation on \(n\) as follows:

\[ n_{next} = \sum_{d \in D(n)} d^2, \]

where \(D(n)\) is the set of decimal digits of \(n\). Your task is to determine if by repeatedly applying this transformation the sequence will eventually become 1 (in which case there is No Cycle) or fall into a cycle (in which case output Cycle). For example, when \(n = 19\):

\( 19 \to 1^2+9^2 = 82 \to 8^2+2^2 = 68 \to \cdots \to 1 \) so the output should be No Cycle.

However, for \(n = 116\), the sequence eventually loops without reaching 1, so the output is Cycle.

inputFormat

The input consists of a single integer \(n\) provided via standard input.

outputFormat

Output a single string: either Cycle if the sequence falls into a cycle or No Cycle if the sequence reaches 1. The output should be printed to standard output.

## sample
19
No Cycle

</p>