Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _08_CountOfEqualBitPairs {
- public static void main(String[] args) {
- Scanner inputNum = new Scanner(System.in);
- long number = inputNum.nextLong();
- String binary = Long.toBinaryString(number);
- long binRep = Long.parseLong(binary);
- long binSubtr = binRep;
- long count = 0;
- for (int i = 0; i < binary.length(); i++) {
- long left = binSubtr;
- left = binSubtr%100;
- binSubtr/=10;
- if (left==11||left==0) {
- count++;
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement