QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#7727. 线性渐变

統計

在欧几里得平面上有一个梯形,其顶点分别为 $(x_1, y_1), (x_1, y_2), (x_2, y_3), (x_2, y_4)$,该梯形被涂上了线性渐变色(定义如下)。

令三元实数 $(r, g, b)$ 表示一个点的颜色,我们用它来定义三种颜色: 红色:$r \ge 150, g \le 75, b \le 75$; 绿色:$g \ge 150, r \le 75, b \le 75$; * 蓝色:$b \ge 150, r \le 75, g \le 75$。

该梯形由一组线段覆盖,这些线段共同构成了整个梯形的区域并产生颜色渐变。该集合定义如下: 集合中的每条线段由一个值 $t$ ($t \in [0, 1]$) 定义。 线段的端点分别为 $(x_1, (1 - t)y_1 + ty_2)$ 和 $(x_2, (1 - t)y_3 + ty_4)$。 左端点的颜色为 $(r_\ell, g_\ell, b_\ell)$,右端点的颜色为 $(r_r, g_r, b_r)$。 线段上内部点的颜色由左端点和右端点颜色之间的线性插值(定义见“说明”)决定,基于该点距离左端点的距离。

计算梯形中红色、蓝色和绿色部分的面积。

输入格式

第一行包含整数 $x_1, y_1, y_2, r_\ell, g_\ell, b_\ell$。 第二行包含整数 $x_2, y_3, y_4, r_r, g_r, b_r$。

数据范围

  • $0 \le x_1 < x_2 \le 100\,000$;
  • $0 \le y_1 < y_2 \le 100\,000$;
  • $0 \le y_3 < y_4 \le 100\,000$;
  • $0 \le r_\ell, g_\ell, b_\ell, r_r, g_r, b_r \le 255$。

输出格式

输出三个实数:分别为红色区域面积、蓝色区域面积和绿色区域面积。绝对误差或相对误差不应超过 $10^{-9}$。

样例

样例输入 1

0 0 50 255 0 0
100 0 100 0 255 0

样例输出 1

1686.851211072
2724.913494800
0.000000000

说明

线性插值是一种基于区间端点已知值来估计区间内数值的方法。在颜色插值的语境下,这意味着颜色分量 $(r, g, b)$ 是通过左端点和右端点对应分量的加权平均值计算得出的,权重由该点距离左端点和右端点的相对距离决定。这在线段上创造了平滑的颜色过渡。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.