Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //using System.Numerics;
- class DancingBits
- {
- static void Main()
- {
- int equalBitsK = int.Parse(Console.ReadLine());
- int numbersN = int.Parse(Console.ReadLine());
- string binarySum = null;
- for (int i = 1; i <= numbersN; i++)
- {
- int usedNumber = int.Parse(Console.ReadLine());
- string binaryValue = Convert.ToString(usedNumber, 2);
- binarySum = binarySum + binaryValue;
- }
- char[] charArr = binarySum.ToCharArray();
- int counterOne = 1;
- int counterTwo = 0;
- int counterThree = 0;
- int[] intArray = new int[charArr.Length];
- for (int c = 0; c < (charArr.Length); c++)
- {
- counterThree++;
- intArray[c] = (int)Char.GetNumericValue(charArr[c]);
- }
- for (int c = 0; c < (charArr.Length-1); c++)
- {
- if (intArray[c] == intArray[c+1])
- {
- counterOne++;
- }
- else if (intArray[c] != intArray[c + 1])
- {
- if (equalBitsK == counterOne)
- {
- counterTwo++;
- }
- counterOne = 1;
- }
- if (counterThree == c + 2)
- {
- if (equalBitsK == counterOne)
- {
- counterTwo++;
- }
- }
- }
- Console.WriteLine(counterTwo);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement