cf View Angle

View Angle


Description

Flatland has recently introduced a new type of an eye check for the driver‘s licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coordinates and with all mannequins standing inside or on the boarder of this angle.

As you spend lots of time "glued to the screen", your vision is impaired. So you have to write a program that will pass the check for you.

Input

The first line contains a single integer n (1?≤?n?≤?105) — the number of mannequins.

Next n lines contain two space-separated integers each: xi,?yi (|xi|,?|yi|?≤?1000) — the coordinates of the i-th mannequin. It is guaranteed that the origin of the coordinates has no mannequin. It is guaranteed that no two mannequins are located in the same point on the plane.

Output

Print a single real number — the value of the sought angle in degrees. The answer will be considered valid if the relative or absolute error doesn‘t exceed 10?-?6.

Sample Input

Input

22 00 2

Output

90.0000000000

Input

32 00 2-2 2

Output

135.0000000000

Input

42 00 2-2 00 -2

Output

270.0000000000

Input

22 11 2

Output

36.8698976458

Hint

【题解】

atan2函数与 atan 的不同

atan2 比 atan 稳定。

如:atan(y/x),当 y 远远大于 x 时,计算结果是不稳定的。

atan2(y,x)的做法:当 x 的绝对值比 y 的绝对值大时使用 atan(y/x);反之使用 atan(x/y)。这样就保证了数值稳定性。

本题必须用atan2,否则不能得出正确答案。

AC代码:

 1 #include<cstdio>
 2 #include<cmath>
 3 #include<algorithm>
 4 using namespace std;
 5
 6 #define pai acos(-1.0)
 7 #define maxn 100005
 8
 9 int main()
10 {
11     int n;
12     double a[maxn], b;
13     scanf("%d", &n);
14     for(int i=0; i<n; i++)
15     {
16         scanf("%lf %lf", &a[i], &b);
17         a[i] = atan2(b, a[i]);
18     }
19     sort(a, a+n);
20     a[n] = a[0] + 2 * pai;
21     double ans = 2*pai;
22     for(int i=0; i<n; i++)
23     {
24         ans = min(ans, 2 * pai - fabs(a[i+1] - a[i]));
25     }
26     printf("%lf\n", ans*180.0/pai);
27     return 0;
28 }  
时间: 2024-10-10 00:49:50

cf View Angle的相关文章

Opengl中矩阵和perspective/ortho的相互转换

Opengl中矩阵和perspective/ortho的相互转换 定义矩阵 Opengl变换需要用四维矩阵.我们来定义这样的矩阵. +BIT祝威+悄悄在此留下版了个权的信息说: 四维向量 首先,我们定义一个四维向量vec4. 1 /// <summary> 2 /// Represents a four dimensional vector. 3 /// </summary> 4 public struct vec4 5 { 6 public float x; 7 public f

OpenGL ES 简单教程

什么是OpenGL ES? OpenGL ES (为OpenGL for Embedded System的缩写) 为适用于嵌入式系统的一个免费二维和三维图形库. 为桌面版本号OpenGL 的一个子集. OpenGL ES 定义了一个在移动平台上可以支持OpenGL最基本功能的精简标准.以适应如手机.PDA或其他消费者移动终端的显示系统. Khronos Group 定义和管理了OpenGL ES标准. OpenGL 与 OpenGL ES的关系OpenGL ES 是基于桌面版本号OpenGL 的

03-VTK基础概念(2)

3.3 光照 剧场里有各式各样的灯光,三维渲染场景中也一样,可以有多个光照存在.光照和相机是三维渲染场景必备的因素,如果没有指定(像3.1.1_RenderCylinder例子,我们没有给Renderer指定相机和光照),vtkRenderer会自动地创建默认的光照和相机.VTK里用类vtkLight来表示渲染场景中的光照.与现实中的灯光类似,VTK中的vtkLight实例也可以打开.关闭,设置光照的颜色,照射位置(即焦点),光照所在的位置,强度等等. vtkLight可以分为位置光照(Posi

Generate contour plot in GNU Octave

Step 1: generating the grid points for the 2D contour plot: [xx, yy] = meshgrid(x_start:dx:x_end, y_start:dy:y_end); Step 2: Calculate the data values at those grid points: where x, y, z are three arrays holding all the source data. zz = griddata(x,

旋转扫描实体示例:vtkQuadRotationalExtrusionFilter

vtkQuadRotationalExtrusionFilter Detailed Description sweep polygonal data creating "skirt" from free edges and lines, and lines from vertices vtkQuadRotationalExtrusionFilter is a modeling filter. It takes polygonal data as input and generates

Matlab中所有自定义的函数

Functions By Category | Alphabetical List Language Fundamentals Entering Commands ans Most recent answer clc Clear Command Window diary Save Command Window text to file format Set display format for output home Send cursor home iskeyword Determine wh

Video processing systems and methods

BACKGROUND The present invention relates to video processing systems. Advances in imaging technology have led to high resolution cameras for personal use as well as professional use. Personal uses include digital cameras and camcorders that can captu

gluPerspective

Name gluPerspective — set up a perspective projection matrix C Specification void gluPerspective( GLdouble fovy,   GLdouble aspect,   GLdouble zNear,   GLdouble zFar); Parameters fovy Specifies the field of view angle, in degrees, in the y direction.

OpenSCAD三维造型设计语言

cube Creates a cube at the origin of the coordinate system. When center is true the cube will be centered on the origin, otherwise it is created in the first octant. The argument names are optional if the arguments are given in the same order as spec