AtCoder Beginner Contest 336 B题解

Problem Statement

For a positive integer �X, let ctz(�)ctz(X) be the (maximal) number of consecutive zeros at the end of the binary notation of �X.
If the binary notation of �X ends with a 11, then ctz(�)=0ctz(X)=0.

You are given a positive integer �N. Print ctz(�)ctz(N).

Constraints

  • 1≤�≤1091≤N≤109
  • �N is an integer.

Input

The input is given from Standard Input in the following format:

�N

Output

Print ctz(�)ctz(N).


Sample Input 1Copy

Copy

2024

Sample Output 1Copy

Copy

3

20242024 is 11111101000 in binary, with three consecutive 0s from the end, so ctz(2024)=3ctz(2024)=3.
Thus, print 33.


Sample Input 2Copy

Copy

18

Sample Output 2Copy

Copy

1

1818 is 10010 in binary, so ctz(18)=1ctz(18)=1.
Note that we count the trailing zeros.


Sample Input 3Copy

Copy

5

Sample Output 3Copy

Copy

0

重要的在十进制转二进制

#include
#include
#define MAX 64
using namespace std;
int main()
{
    int i=0,n,a[MAX];
    cin>>n;
    while (n>0)   
    {
        a[i] = n%2;   
        i = i+1;
        n = n/2;
    }
    int js=0;
    for(int j=0;j

你可能感兴趣的:(算法)