#C8798. Magical Transformations

    ID: 52819 Type: Default 1000ms 256MiB

Magical Transformations

Magical Transformations

You are given a list of positive integers (stones). For each stone, you need to determine how many transformations are required for the number to reach 1 using the following magical rules:

  • If n is even, then n becomes \(\frac{n}{2}\).
  • If n is odd and not 1, then n becomes \(3n + 1\).

The process is repeated until the number becomes 1. Your task is to compute these transformation counts for a list of stones.

Example:

Input:  3
       6 19 27
Output: 8 20 111

inputFormat

The input is given from stdin and has the following format:

  1. The first line contains a single integer \(T\) which indicates the number of stones.
  2. The second line contains \(T\) space-separated positive integers representing the values of each stone.

Note: \(T\) can be zero, in which case no stones are provided.

outputFormat

Print a single line to stdout consisting of \(T\) space-separated integers. Each integer represents the number of transformations required for the corresponding stone to reach 1.

## sample
3
6 19 27
8 20 111