博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 257C View Angle :二维平面上一些点,从原点射出两条射线将它们全部包括,求最小夹角 :几何+技巧...
阅读量:7120 次
发布时间:2019-06-28

本文共 944 字,大约阅读时间需要 3 分钟。

将每个点与x正半轴夹角利用atan求出来,都在[0,360)之间

然后排序,枚举夹角相邻的两个点,ans=min(360-(the[i+1]-the[i])) 1<=1<n

注意最后判断下第一条和最后一条之间夹角

1 #include
2 #include
3 #include
4 #include
5 #define eps 1e-10 6 using namespace std; 7 double the[100005]; 8 int main() 9 {10 int n,i;11 double x,y,minx;12 scanf("%d",&n);13 for (i=1;i<=n;i++)14 {15 scanf("%lf%lf",&x,&y);16 if (x==0) {17 if (y>0) the[i]=90;18 else the[i]=270;19 }20 else{21 the[i]=atan(y/x)*180/3.141592653579793;22 if (fabs(the[i])<=eps){23 if (x<0) the[i]=180;24 }25 else if (the[i]<=eps) {26 if (x>0) the[i]+=360;27 else the[i]+=180;28 }29 else if (x<0) the[i]+=180;30 }31 }32 sort(the+1,the+n+1);33 minx=the[n]-the[1];34 for (i=1;i
View Code

题目链接:

转载于:https://www.cnblogs.com/xiao-xin/articles/4369104.html

你可能感兴趣的文章
String path = request.getContextPath
查看>>
MVC学习二:基础语法
查看>>
最长公共子序列(LCS)问题 Longest Common Subsequence 与最长公告字串 longest common substr...
查看>>
Erlang中一些错误或者异常的标识
查看>>
OpenCV 编程简单介绍(矩阵/图像/视频的基本读写操作)
查看>>
NGUI全面实践教程(大学霸内部资料)
查看>>
Windows下PowerShell监控Keepalived
查看>>
一个游戏程序员的学习资料
查看>>
UIMenuController,UIPasteboard:复制,粘贴详细解释
查看>>
js在以div添加滚动条
查看>>
thinkphp 如何调用百度echarts 数据报表插件
查看>>
Git异常:fatal: V1.0 cannot be resolved to branch.
查看>>
Atitit.web的自动化操作与信息抓取 attilax总结
查看>>
csdn android视频播放器开发
查看>>
lintcode:线段树的构造
查看>>
could not be installed at this time
查看>>
随机函数(Pascal入门)
查看>>
【NLP】蓦然回首:谈谈学习模型的评估系列文章(一)
查看>>
Java传值和传址
查看>>
两种常用的启动和关闭MySQL服务
查看>>