CF1167G.Low Budget Inception

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

So we got bored and decided to take our own guess at how would "Inception" production go if the budget for the film had been terribly low.

The first scene we remembered was the one that features the whole city bending onto itself:

It feels like it will require high CGI expenses, doesn't it? Luckily, we came up with a similar-looking scene which was a tiny bit cheaper to make.

Firstly, forget about 3D, that's hard and expensive! The city is now represented as a number line (infinite to make it easier, of course).

Secondly, the city doesn't have to look natural at all. There are nn buildings on the line. Each building is a square 1×11 \times 1 . Buildings are numbered from 11 to nn in ascending order of their positions. Lower corners of building ii are at integer points aia_i and ai+1a_i + 1 of the number line. Also the distance between any two neighbouring buildings ii and i+1i + 1 doesn't exceed dd (really, this condition is here just to make the city look not that sparse). Distance between some neighbouring buildings ii and i+1i + 1 is calculated from the lower right corner of building ii to the lower left corner of building i+1i + 1 .

Finally, curvature of the bend is also really hard to simulate! Let the bend at some integer coordinate xx be performed with the following algorithm. Take the ray from xx to ++\infty and all the buildings which are on this ray and start turning the ray and the buildings counter-clockwise around point xx . At some angle some building will touch either another building or a part of the line. You have to stop bending there (implementing buildings crushing is also not worth its money).

Let's call the angle between two rays in the final state the terminal angle αx\alpha_x .

The only thing left is to decide what integer point xx is the best to start bending around. Fortunately, we've already chosen mm candidates to perform the bending.

So, can you please help us to calculate terminal angle αx\alpha_x for each bend xx from our list of candidates?

输入格式

The first line contains two integer numbers nn and dd ( 1n21051 \le n \le 2 \cdot 10^5 , 0d70000 \le d \le 7000 ) — the number of buildings and the maximum distance between any pair of neighbouring buildings, respectively.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( a1=0a_1 = 0 , 0<ai+1aid+10 < a_{i + 1} - a_i \le d + 1 ) — coordinates of left corners of corresponding buildings in ascending order.

The third line contains single integer mm ( 1m21051 \le m \le 2 \cdot 10^5 ) — the number of candidates.

The fourth line contains mm integers x1,x2,,xmx_1, x_2, \dots, x_m ( 0xian+10 \le x_i \le a_n + 1 , xi<xi+1x_i < x_{i + 1} ) — the coordinates of bends you need to calculate terminal angles for in ascending order.

输出格式

Print mm numbers. For each bend xix_i print terminal angle αxi\alpha_{x_i} (in radians).

Your answer is considered correct if its absolute error does not exceed 10910^{-9} .

Formally, let your answer be aa , and the jury's answer be bb . Your answer is accepted if and only if ab109|a - b| \le 10^{-9} .

输入输出样例

  • 输入#1

    3 5
    0 5 7
    9
    0 1 2 3 4 5 6 7 8
    

    输出#1

    1.570796326794897
    1.570796326794897
    0.785398163397448
    0.927295218001612
    0.785398163397448
    1.570796326794897
    1.570796326794897
    1.570796326794897
    1.570796326794897
    
  • 输入#2

    2 7
    0 4
    3
    1 3 4
    

    输出#2

    1.570796326794897
    0.927295218001612
    1.570796326794897
    
  • 输入#3

    5 0
    0 1 2 3 4
    6
    0 1 2 3 4 5
    

    输出#3

    1.570796326794897
    3.141592653589793
    3.141592653589793
    3.141592653589793
    3.141592653589793
    1.570796326794897
    

说明/提示

Here you can see the picture of the city for the first example and the bend at position 22 for it. The angle you need to measure is marked blue. You can see that it's equal to π4\frac \pi 4 .

You can see that no pair of neighbouring buildings have distance more than 44 between them. d=4d = 4 would also suffice for that test.

首页