Thứ Hai, 22 tháng 4, 2019

Cho mot so nhi phan, tim luy thua cao nhat cua 2 la uoc cua so nay

Given a binary number (of bits)
. Find the highest power of 2 that divides this number.
Note: If the binary number is "100" then the highest power of 2 that divides it is 2 (as = 4)

Input:

  • The first line contains N the number of bits in the number
  • The next line contains a binary number of N bits

Output:

  • The first and only line contains the max power of 2 that divides the given number

Constraints:



    Sample Input:

    5
    10100

    Sample Output:

    2

    Không có nhận xét nào:

    Đăng nhận xét