Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BinaryDigitsCount
- {
- static void Main()
- {
- byte bitNum = byte.Parse(Console.ReadLine());
- short countOfNumbers = short.Parse(Console.ReadLine());
- for (int i = 1; i <= countOfNumbers; i++)
- {
- int countOfBits = 0;
- uint number = uint.Parse(Console.ReadLine());
- while (number != 0)
- {
- if ((number & 1) == bitNum)
- {
- countOfBits++;
- }
- number = number >> 1;
- }
- Console.WriteLine(countOfBits);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment