Advertisement
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;
- class BitSifting
- {
- static void Main()
- {
- long number = long.Parse(Console.ReadLine());
- string binaryNumber = Convert.ToString(number, 2).PadLeft(64, '0');
- char[] binaryNum = binaryNumber.ToCharArray();
- int loop = int.Parse(Console.ReadLine());
- char[] result = new char[64];
- string resultFull = "";
- result = binaryNum;
- int counter = 0;
- for (int i = 0; i < loop; i++)
- {
- long sifting = long.Parse(Console.ReadLine());
- string binarySifting = Convert.ToString(sifting, 2).PadLeft(64, '0');
- char[] BinarySift = binarySifting.ToCharArray();
- for (int k = 0; k < 64; k++)
- {
- if (result[k] == BinarySift[k] && result[k] == '1')
- {
- result[k] = '0';
- }
- }
- }
- for (int i = 0; i < 64; i++)
- {
- if (result[i] == '1')
- {
- counter ++;
- }
- }
- Console.WriteLine(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement