CF82E.Corridor

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider a house plan.

Let the house be represented by an infinite horizontal strip defined by the inequality  - h ≤ y ≤ h. Strictly outside the house there are two light sources at the points (0, f) and (0,  - f). Windows are located in the walls, the windows are represented by segments on the lines y = h and y =  - h. Also, the windows are arranged symmetrically about the line y = 0.

Your task is to find the area of the floor at the home, which will be lighted by the sources of light.

考虑一个房屋的平面图。

设该房屋由满足不等式 −h≤y≤h-h \le y \le h 的无限水平条带表示。房屋外部(严格在条带之外)有两个光源,分别位于点 (0,f)(0, f) 和 (0,−f)(0, -f)。窗户位于墙壁上,即分别位于直线 y=hy = h 和 y=−hy = -h 上的线段;此外,这些窗户关于直线 y=0y = 0 对称。

你的任务是求出房屋地板(即条带内部区域)中被光源照亮部分的面积。

输入格式

The first line of the input file contains three integers n, h and f (1 ≤ n ≤ 500, 1 ≤ h ≤ 10, h < f ≤ 1000). Next, n lines contain two integers each l__i, r__i ( - 5000 ≤ l__i < r__i ≤ 5000), each entry indicates two segments. Endpoints of the first segment are (l__i, h)-(r__i, h), and endpoints of the second segment are (l__i,  - h)-(r__i,  - h). These segments describe location of windows. Numbers in the lines are space-separated. It is guaranteed that no two distinct segments have common points.

输入文件的第一行包含三个整数 nn、hh 和 ff(1 ≤ n ≤ 5001 ≤ n ≤ 500,1 ≤ h ≤ 101 ≤ h ≤ 10,h < f ≤ 1000h < f ≤ 1000)。接下来的 nn 行每行包含两个整数 lil_i、rir_i(−5000 ≤ li < ri ≤ 5000-5000 ≤ l_i < r_i ≤ 5000),每对数表示两条线段:第一条线段的端点为 (li, h)(l_i,\,h)–(ri, h)(r_i,\,h),第二条线段的端点为 (li, −h)(l_i,\,-h)–(ri, −h)(r_i,\,-h)。这些线段描述了窗户的位置。每行中的数字以空格分隔。保证任意两条不同的线段之间没有公共点。

输出格式

Print the single real number — the area of the illuminated part of the floor with an absolute or relative error of no more than 10 - 4.

输出一个实数——地板被照亮部分的面积,要求绝对或相对误差不超过 10−410^{-4}。

输入输出样例

  • 输入#1

    1 1 2
    -1 1

    输出#1

    10.0000000000
  • 输入#2

    2 2 4
    -1 0
    1 2

    输出#2

    23.3333333333

说明/提示

The second sample test is shown on the figure. Green area is the desired area of the illuminated part of the floor. Violet segments indicate windows.

第二个样例测试如图所示。绿色区域为地板上被照亮部分的期望面积。紫色线段表示窗户。

输入解题思路,AI测评打分。不知道怎么写?

首页