hacktoberfest2021 icon indicating copy to clipboard operation
hacktoberfest2021 copied to clipboard

Odd GCD

Open kartik-ey1 opened this issue 3 years ago • 3 comments

You are given an array A1,A2,…,AN consisting of N integers. Your goal is to make the GCD of all the elements in the array an odd integer. To achieve this goal, you can do the following operation any number of times:

Choose an index i(1≤i≤N) such that Ai>1 and set Ai=⌊Ai2 ⌋ You can choose an index multiple times during the operations. Find the minimum number of operations after which GCD of all the elements in the array becomes an odd integer.

Note: ⌊x⌋ : Returns the largest integer that is less than or equal to x (i.e rounds down to the nearest integer). For example, ⌊1.5⌋=1,⌊2⌋=2, ⌊72 ⌋ =⌊3.5⌋ =3.

Input Format The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N. The second line contains N space-separated integers A1,A2,…,AN. Output Format For each test case, print a single line containing one integer - the minimum number of operations after which GCD of all the elements in the array becomes an odd integer.

problem link https://www.codechef.com/START14C/problems/BININVER

kartik-ey1 avatar Oct 03 '21 11:10 kartik-ey1

i want to add this in cpp program section please assign this to me

kartik-ey1 avatar Oct 03 '21 11:10 kartik-ey1

@rjkalash

kartik-ey1 avatar Oct 03 '21 11:10 kartik-ey1

I would like to add solution of this problem.

viveknamaye avatar Oct 03 '21 15:10 viveknamaye