C#. Пример работы на изображении. (Входные данные отличаются)
using System;
using System.Collections.Generic;
using System.Linq;
namespace NSymbs
{
class Program
{
static void Main(string[] args)
{
string input;
input = Console.ReadLine();
int[] param = input.Split("\t ".ToCharArray()).Select(x => int.Parse(x)).ToArray();
input = Console.ReadLine();
int z = input.Length / param[1];
List<string> bufer = new List<string>();
for (int i = 0; i < z; ++i)
bufer.Add(input.Substring(i*param[1], param[1]));
Console.WriteLine(bufer.Distinct().Count());
}
}
}
function Dec2Bin(t: integer): string;
begin
var r: string := '';
while t >= 2 do
(r, t) := (t mod 2 + r, t shr 1);
r := t + r;
Result := '0' * (8 - r.Length) + r
end;
function Bin2Dec(s: string): integer;
begin
Result := 0;
var p := 1;
for var i := s.Length downto 1 do
begin
Result += (s[i].ToDigit) * p;
p *= 2
end
end;
function GenSeqCycle(n: integer): sequence of integer;
begin
var s := Dec2Bin(n);
loop 8 do
begin
yield Bin2Dec(s);
s := s[2:] + s[1]
end
end;
begin
GenSeqCycle(ReadInteger).Max.Println
end.