Fişierul intrare/ieşire:occurences.in, occurences.outSursăIIOT 2021-22 Runda 2
AutorVlad AndriesAdăugată destefdascalescuStefan Dascalescu stefdascalescu
Timp execuţie pe test0.25 secLimită de memorie32768 kbytes
Scorul tăuN/ADificultateN/A

Vezi solutiile trimise | Statistici

Maximum 0ccurrences

You are given an integer n and you have to do one operation at a time:

1. If n is odd, you must multiple it by 3 and add 1 to the result.

2. If n is even, you must divide it by 2.

What is the number with maximum occurrences if you do 10^100 operations on the given number n?

Date de intrare

The first line of the file occurences.in will contain t, the number of test cases.

Each of the next t lines will contain a single number n, .

Date de ieşire

On each line of the output file occurences.out we will print an integer, representing the answer to the problem. If there are multiple solutions, print the biggest one of them.

Restricţii

  • 1 ≤ n ≤ 10^18
  • 1 ≤ t ≤ 10^5
  • For tests worth 50 points, 1 ≤ n ≤ 1000.

Exemplu

occurences.inoccurences.out
3
2
18
1
2
4
1

Explicaţie

For the first sample test case, the numbers printed will be 2, 1, 4, 2, 1, ..., and therefore 2 and 1 will show up one more time than the other numbers. Since we need to print the biggest integer, then we will print 2.

Trebuie sa te autentifici pentru a trimite solutii. Click aici

Cum se trimit solutii?