Editorial for DMOPC '18 Contest 3 P0 - Bob and ICS Class

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Authors: Kirito

For this problem, we are given two triples of nonnegative integers (R_1, G_1, B_1) and (R_2, G_2, B_2) and we wish to determine if the tuples (\lfloor \sqrt{R_1} \rfloor, \lfloor \sqrt{G_1} \rfloor, \lfloor \sqrt{B_1} \rfloor) and (\lfloor \sqrt{R_2} \rfloor, \lfloor \sqrt{G_2} \rfloor, \lfloor \sqrt{B_2} \rfloor) are identical.

Most programming languages have a function that takes in a nonnegative number and outputs the square root of that number as a floating-point number. Similarly, most languages will allow you to cast that floating-point number to an integer which will remove the decimal part of the number.

Therefore, to check if x_1 and x_2 will be the same, we can compute (int)sqrt(x_1) and (int)sqrt(x_2) and see if they are equal, and repeat this for each of the other pairs of numbers that we need to compare.


There are no comments at the moment.