#include <iostream>
#include <random>

struct Color {
	Color(unsigned char r, unsigned char g, unsigned char b) : r(r), g(g), b(b) {}
	unsigned char r, g, b;
};

std::ostream &operator<<(std::ostream &out, const Color &c) {
	return out << "(" << (int)c.r << ", " << (int)c.g << ", " << (int)c.b << ")";
}

Color random_color(int j, std::mt19937 &gen) {
	std::uniform_int_distribution<int> distrib(1, 0xFFFFFF);
	int color = distrib(gen);
	int r = color & 0xFF;
	int g = (color >> 8) & 0xFF;
	int b = (color >> 16) & 0xFF;
	
	double l = sqrt(0.299*r*r + 0.587*g*g + 0.114*b*b);
	double c = j/l;
	return Color(c*r, c*g, c*b);
}


int main() {
	std::random_device rd;
	std::mt19937 gen(rd());
	
	for (int j : { 0, 1, 2, 10, 50, 100, 200, 243, 254, 255 }) {
		std::cout << "j = " << j << ", color = " << random_color(j, gen) << std::endl; 
	}
}