DMOPC '18 Contest 5 P0 - A Digital Art Problem

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

The Multiply, Screen, and Overlay blend modes in image manipulation programs such as Photoshop are very useful when making digital art. If you apply one of these modes to a base colour and a top colour, a resulting colour is produced. Colours have three components: R, G, and B, which can have any real value from 0 to 1 (completely dark to completely light) inclusive, and modes operate on each component separately. Let's call a component of the base colour Xa and the same component of the top colour Xb.

If you apply the Multiply mode, the resulting component will be XaXb. As this produces a darker colour, it is good for drawing shadows.

If you apply the Screen mode, the resulting component will be 1(1Xa)(1Xb). As this produces a lighter colour, it is good for drawing highlights.

The Overlay mode produces different results depending on the base component. If this component is less than 0.5, the resulting value is 2XaXb. Otherwise, the resulting value is 12(1Xa)(1Xb). As this makes dark colours darker and light colours lighter, it is good for adding contrast.

Given a blend mode and each component of the base and top colours, please find the resulting colour.

Input Specification

The first line will contain one of the following strings: Multiply, Screen, or Overlay, the blend mode.
The second line will contain 3 space-separated real numbers: Ra, Ga, and Ba representing each component of the base colour.
The third and final line will contain 3 space-separated real numbers: Rb, Gb, and Bb representing each component of the top colour.

Output Specification

Output 3 space-separated real numbers on one line: the R, G, and B of the resulting colour.
Your answer will be judged correct if it has an absolute or relative error less than or equal to 106.

Sample Input

Copy
Multiply
0.30 0.22 0.90
0.52 0.12 0.03

Sample Output

Copy
0.156000 0.026400 0.027000

Comments

There are no comments at the moment.