codeforces 257 C. View Angle
来源:互联网 发布:燕窝真的有用吗 知乎 编辑:程序博客网 时间:2024/04/28 14:10
题目:http://codeforces.com/contest/257/problem/C
极角序。使用atan2(y,x)排序。
这题很容易做错的一点就是开始会想到直接用sort升序排序后,最大减去最小即是所求,其实这是不对的。比如给三点:(-1,-1),(-1,1),(-1,2)测一下。
每个黄色区域的两边上的两点肯定是相邻的,我们可以根据这个已知项来解答:
本题我觉得还是很有思维性的。
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;struct Point{ double x; double y; double angle;};Point p[100003];bool cmp(Point a,Point b){ return a.angle<b.angle;}int main(){ int n; scanf(" %d",&n); for(int i=0; i<n; i++) { scanf(" %lf %lf",&p[i].x,&p[i].y); p[i].angle = atan2(p[i].y,p[i].x); } sort(p,p+n,cmp); p[n].angle = p[0].angle + 2 * acos(-1.0); double ans = 2*acos(-1.0); for(int i=0; i<n; i++) { ans = min(ans,2 * acos(-1.0) - fabs(p[i+1].angle - p[i].angle)); } printf("%lf\n",ans*180.0/acos(-1.0)); return 0;}
- codeforces 257 C. View Angle
- CodeForces 257C View Angle
- CodeForces 257C. View Angle
- codeforces - 257c View Angle 【数学】
- codeforces 257 C. View Angle (数学)
- Codeforces 257C View Angle 几何(角度)
- Codeforces 257C:View Angle(思维+数学+atan2函数)
- CodeForces 257C View Angle(求角度)
- CodeForces - 257C View Angle 【极角排序】
- 【CodeForces】257C - View Angle(计算几何)
- **View Angle
- angle
- Angle
- 相机的Angle of View, Field of view && Focal length
- Codeforces 820B Mister B and Angle in Polygon
- Codeforces#421 Mister B and Angle in Polygon
- codeforces 820B Mister B and Angle in Polygon
- CodeForces 820B Mister B and Angle in Polygon
- 配合m2eclipse创建一个标准的maven web项目
- 用JAVA SOCKET发送和接收文件
- 火狐浏览器个人设置保存备份即归档文件问题
- Java开源建站工具
- 7个改变世界的Java项目
- codeforces 257 C. View Angle
- android 线程学习
- 浅谈java中的四个核心概念
- Shell数值及字符串比较
- 2道腾讯面试的C++题目
- bitmap思想及其在java中的相关实现
- Ejb的完整build.xml
- hello world
- CocoaPods的安装和使用