Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class _21BitSifting
- {
- static void Main()
- {
- ulong bits = ulong.Parse(Console.ReadLine());
- int n = int.Parse(Console.ReadLine());
- ulong count = 0;
- for (int i = 0; i < n; i++)
- {
- ulong sieve = ulong.Parse(Console.ReadLine());
- bits = bits & (~sieve);
- }
- while (bits != 0) // until all bits are zero
- {
- if ((bits & 1) == 1) // check lower bit
- {
- count++;
- bits >>= 1; // shift bits, removing lower bit
- }
- }
- Console.WriteLine(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement