using System;
// CMYK = Cyan, Magenta, Yellow, Key(black)
// RGB = Red, Green, Blue
public class MyClass
{
private static double[] RGBtoCMYK(double R, double G, double B) {
if (R == 0 && G == 0 && B == 0) {
return new double[]{0, 0, 0, 1};
}
R = R / 255.0 * 100;
G = G / 255.0 * 100;
B = B / 255.0 * 100;
double K = 100 - Math.Max(Math.Max((int)R, (int)G), (int)B);
if (K == 100) {
return new double[]{0, 0, 0, 100};
}
double C = Math.Round((100 - R - K) / (100 - K) * 100, MidpointRounding.AwayFromZero);
double M = Math.Round((100 - G - K) / (100 - K) * 100, MidpointRounding.AwayFromZero);
double Y = Math.Round((100 - B - K) / (100 - K) * 100, MidpointRounding.AwayFromZero);
return new double[]{C, M, Y, K};
}
public static void Main(string[] args)
{
double[] CMYK = RGBtoCMYK(245.0f, 213.0f, 0.0f);
Console.WriteLine(string.Join(" ", CMYK));
}
}
/*
run:
0 13 100 4
*/