#include <iostream>
#include <memory>
#include <vector>
#include <ctime>
#include <algorithm>

static const uint64_t SEED = 0xDEADBEEFull;
static const uint32_t COLORS_NUM = 2;
static uint64_t next = SEED;
uint32_t LCGRand()
{
    next = next * 6364136223846793005 + 1442695040888963407;
    return next >> 32;
}

void resetLCGRand()
{
    next = SEED;
}

float getEmaxAvg(size_t sequenceLen, size_t sequencesCount = 30)
{
    size_t sum = 0;
    for (size_t tries = 0; tries < sequencesCount; tries++) {
        uint32_t lastColor = LCGRand();
        size_t currentSequence = 1;
        size_t maxSequence = 0;
        for (size_t i = 1; i < sequenceLen; i++) {
            uint32_t color = LCGRand() % COLORS_NUM;
            if (color != lastColor) {
                maxSequence = std::max(maxSequence, currentSequence);
                currentSequence = 1;
            } else {
                ++currentSequence;
            }
            lastColor = color;
        }
        sum += maxSequence;
    }
    return (float)sum / sequencesCount;
}

int main()
{
    resetLCGRand();

    for (auto && seqLen : { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }) {
        std::cout << seqLen << "," << getEmaxAvg(seqLen, 30) << std::endl;
    }
    return 0;
}
