CF47E.Cannon
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, the origin of which coincides with the cannon's position, the Ox axis is directed rightwards in the city's direction, the Oy axis is directed upwards (to the sky). The cannon will make n more shots. The cannon balls' initial speeds are the same in all the shots and are equal to V, so that every shot is characterized by only one number alpha__i which represents the angle at which the cannon fires. Due to the cannon's technical peculiarities this angle does not exceed 45 angles (π / 4). We disregard the cannon sizes and consider the firing made from the point (0, 0).
The balls fly according to the known physical laws of a body thrown towards the horizon at an angle:
v__x(t) = V·cos(alpha)
v__y(t) = V·sin(alpha) – g·t
x(t) = V·cos(alpha)·t
y(t) = V·sin(alpha)·t – g·_t_2 / 2
Think of the acceleration of gravity g as equal to 9.8.
Bertown defends m walls. The i-th wall is represented as a vertical segment (x__i, 0) - (x__i, y__i). When a ball hits a wall, it gets stuck in it and doesn't fly on. If a ball doesn't hit any wall it falls on the ground (y = 0) and stops. If the ball exactly hits the point (x__i, y__i), it is considered stuck.
Your task is to find for each ball the coordinates of the point where it will be located in the end.
伯特城正遭受围攻!进攻者已封锁了所有出城道路,其加农炮正在持续轰击城市。幸运的是,贝尔兰德情报部门成功截获了敌方的射击计划。我们建立一个笛卡尔坐标系,坐标原点与加农炮位置重合;Ox 轴指向城市方向(向右),Oy 轴竖直向上(指向天空)。加农炮还将进行 n 次射击。所有炮弹的初速度大小相同,均为 V,因此每次射击仅由一个参数 αi 刻画,即炮管的仰角。受加农炮技术限制,该仰角不超过 45∘(即 π/4)。我们忽略加农炮自身的尺寸,视所有射击均从点 (0,0) 发出。
炮弹的运动遵循经典物理中斜向上抛体运动规律:
vx(t)=V⋅cos(α)
vy(t)=V⋅sin(α)−g⋅t
x(t)=V⋅cos(α)⋅t
y(t)=V⋅sin(α)⋅t−g⋅t2/2
取重力加速度 g=9.8。
伯特城设有 m 道防御墙。第 i 道墙表示为一条竖直的线段:从点 (xi,0) 到点 (xi,yi)。当炮弹击中某道墙时,它将嵌入墙中并停止运动;若未击中任何墙壁,则炮弹最终落于地面(即 y=0 处)并停止。若炮弹恰好击中端点 (xi,yi),亦视为嵌入墙中。
你的任务是:对每一发炮弹,求出其最终静止位置的坐标。
输入格式
The first line contains integers n and V (1 ≤ n ≤ 104, 1 ≤ V ≤ 1000) which represent the number of shots and the initial speed of every ball. The second line contains n space-separated real numbers alpha__i (0 < alpha__i < π / 4) which represent the angles in radians at which the cannon will fire. The third line contains integer m (1 ≤ m ≤ 105) which represents the number of walls. Then follow m lines, each containing two real numbers x__i and y__i (1 ≤ x__i ≤ 1000, 0 ≤ y__i ≤ 1000) which represent the wall’s coordinates. All the real numbers have no more than 4 decimal digits. The walls may partially overlap or even coincide.
第一行包含两个整数 n 和 V(1≤n≤104,1≤V≤1000),分别表示发射炮弹的次数以及每颗炮弹的初始速度。
第二行包含 n 个以空格分隔的实数 αi(0<αi<π/4),表示大炮发射角度(单位为弧度)。
第三行包含一个整数 m(1≤m≤105),表示墙壁的数量。
接下来是 m 行,每行包含两个实数 xi 和 yi(1≤xi≤1000,0≤yi≤1000),表示第 i 面墙的坐标。
所有实数最多保留 4 位小数。墙壁之间可能部分重叠,甚至完全重合。
输出格式
Print n lines containing two real numbers each — calculate for every ball the coordinates of its landing point. Your answer should have the relative or absolute error less than 10 - 4.
输出 n 行,每行包含两个实数——对每个球,计算其落地点的坐标。你的答案需满足相对误差或绝对误差小于 10−4。
输入输出样例
输入#1
2 10 0.7853 0.3 3 5.0 5.0 4.0 2.4 6.0 1.9
输出#1
5.000000000 2.549499369 4.000000000 0.378324889
输入#2
2 10 0.7853 0.3 2 4.0 2.4 6.0 1.9
输出#2
10.204081436 0.000000000 4.000000000 0.378324889
输入解题思路,AI测评打分。不知道怎么写?