-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 11.java
34 lines (30 loc) · 817 Bytes
/
Day 11.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bufferedReader.readLine().trim());
String k=Integer.toBinaryString(n);
int f=k.length(),c=0,m=0;
for(int i=0;i<f;i++)
{
if(k.charAt(i)=='0')
{
c=Math.max(m,c);
m=0;
}
else
{
m++;
}
}
c=Math.max(c,m);
System.out.println(c);
bufferedReader.close();
}
}