Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _8_Problem {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- int countBits = 0;
- while (n > 0){
- int last2Bits = (n >> 32) & 3; // 3 in binnary is 11
- if (last2Bits == 0 || last2Bits == 3)
- {
- countBits++;
- }
- n = n >> 1;
- }
- System.out.println(countBits);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement