Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class DancingBits
- {
- static void Main()
- {
- int k = int.Parse(Console.ReadLine());
- int n = int.Parse(Console.ReadLine());
- int len = 0, index = 0, sequence = 0;
- char lastChar = ' ', charOne =' ';
- string number = "";
- for (int i = 0; i < n; i++)
- {
- int input = int.Parse(Console.ReadLine());
- number += Convert.ToString(input, 2);
- }
- do
- {
- charOne = number[index];
- if(lastChar == charOne)
- {
- len++;
- }
- else
- {
- if (len == k)
- {
- sequence++;
- }
- len = 1;
- }
- lastChar = charOne;
- index++;
- }while (index < number.Length);
- if(len == k)
- {
- sequence++;
- }
- Console.WriteLine(sequence);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment