Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BinaryDigitsCount
- {
- class BinaryDigitsCount
- {
- static void Main(string[] args)
- {
- byte numberB = byte.Parse(Console.ReadLine());
- short numberN = short.Parse(Console.ReadLine());
- for (int i = 0; i < numberN; i++)
- {
- int counter = 0;
- uint currentNumber = uint.Parse(Console.ReadLine());
- while (currentNumber != 0)
- {
- if((currentNumber & 1) == numberB)
- {
- counter++;
- }
- currentNumber >>= 1;
- }
- Console.WriteLine(counter);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment