zh_stoqnov

Bit Sifting

Oct 26th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Bit_Sifting
  4. {
  5. class BitSifting
  6. {
  7. public static void Main(string[] args)
  8. {
  9. ulong bits = ulong.Parse(Console.ReadLine());
  10. int sieves = int.Parse(Console.ReadLine());
  11.  
  12. for(int i = 0; i < sieves; ++i)
  13. {
  14. ulong sieve = ulong.Parse(Console.ReadLine());
  15. bits = bits & (~sieve);
  16. }
  17. ulong bitsCount = 0;
  18. while (bits > 0)
  19. {
  20. bitsCount += (bits & 1);
  21. bits = bits >> 1;
  22. }
  23. Console.WriteLine(bitsCount);
  24.  
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment