Guarding Bananas
Guarding Bananas
Once there was a lazy monkey in a forest. But he loved banana too much. One day there was a storm in the jungle and all the bananas fell from the trees. The monkey didn't want to lose any of the bananas. So, he wanted to find a banana such that he can eat that and he can also look after the other bananas. As he was lazy, he didn't want to move his eyes too wide. So, you have to help him finding the banana from where he can look after all the bananas but the degree of rotating his eyes is as small as possible. You can assume that the position of the bananas can be modeled as 2D points.
Here a banana is shown, from where the monkey can look after all the bananas with minimum eye rotation.
Input
Input starts with an integer T (≤ 13), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 105) denoting the number of bananas. Each of the next n lines contains two integers x y (-109 ≤ x, y ≤ 109) denoting the co-ordinate of a banana. There can me more than one bananas in the same co-ordinate.
Output
For each case, print the case number and the minimum angle in degrees. Errors less than 10-6 will be ignored.
Sample Input
2
1
4 4
4
0 0
10 0
10 10
2 1
Sample Output
Case 1: 0
Case 2: 45.0000000
Hint
Dataset is huge. Use faster I/O methods.
没有什么好说的,求凸包面积,直接上模板.
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; ; const double PI=acos(-1.0); ; :x<?-:;} struct point{double x,y;}a[maxn],ch[maxn]; bool operator < (point x,point y){return x.x<y.x||x.x==y.x&&x.y<y.y;} bool operator == (point x,point y){return x.x==y.x&&x.y==y.y;} point operator - (point x,point y){point ret; ret.x=x.x-y.x,ret.y=x.y-y.y; return ret;} double angle(point x){return atan2(x.y,x.x);} double cross(point x,point y){return x.x*y.y-x.y*y.x;} int Andrew(point *a, int n, point *ch){ sort(a,a+n); ; ; i<n; i++) { &&dcmp(cross(ch[m-]-a[i],ch[m-]-a[i])) <= ) m--; ch[m++]=a[i]; } int k=m; ; i>=; i--) { ]-a[i],ch[m-]-a[i])) <= ) m--; ch[m++]=a[i]; } ) m--; return m; } int main(){ int T,n,ts; ; ts<=T; ts++){ scanf("%d",&n); ; i<n; i++) scanf("%lf%lf", &a[i].x,&a[i].y); ){printf("Case %d: 0.0000000\n",ts); continue;} n=Andrew(a,n,ch); ; i<; i++) ch[i+n]=ch[i]; double mini=1e10; ; i<n; i++){ ]); ]-ch[i+]); double da=fabs(ang1-ang2); if (da>PI) da=2.0*PI-da; mini=min(mini,da*180.0/PI); } printf("Case %d: %.7f\n",ts,mini); } ;
Guarding Bananas的更多相关文章
- LightOJ 1203 Guarding Bananas (凸包最小顶角)
题目链接:LightOJ 1203 Problem Description Once there was a lazy monkey in a forest. But he loved banana ...
- LightOj1203 - Guarding Bananas(凸包求多边形中的最小角)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1203 题意:给你一个点集,求凸包中最小的角:模板题,但是刚开始的时候模板带错了,错的我 ...
- LightOJ 1203--Guarding Bananas(二维凸包+内角计算)
1203 - Guarding Bananas PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 M ...
- Soldier and Bananas
Soldier and Bananas 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=173141 题意: 给 ...
- CodeForces 546A-Soldier and Bananas
题意: 有n dollar,the first banana cost k dollars,第i个就需cost k*i,问买w个bananas是否需要借钱:借钱需要多少? 分析:首先计算w个bana ...
- BZOJ 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场
题目 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 491 S ...
- 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场
1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 498 Solve ...
- [Swift]LeetCode875. 爱吃香蕉的珂珂 | Koko Eating Bananas
Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i]bananas. The gu ...
- Koko Eating Bananas LT875
Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The g ...
随机推荐
- 中文字符串和UTF-8编码字符串相互转换
中文字符串和UTF-8编码字符串相互转换 //UTF字符转换 var UTFTranslate = { Change: function(pValue) { ) { ).replace(/(%u)(\ ...
- 前端调用后端接口下载excel文件的几种方式
今天有一个导出相应数据为excel表的需求.后端的接口返回一个数据流,一开始我用axios(ajax类库)调用接口,返回成功状态200,但是!但是浏览器没有自动下载excel表,当时觉得可能是ajax ...
- Windows下Apache服务器搭建
Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,是世界使用排名第一的Web服务器软件,可以在大多数计算机操作系统中运行,由于其多平台和安全性 ...
- adb shell命令后出现error: device not found错误提示
在cmd中输入adb shell进入linux shell环境前,需要把android模拟器打开(本文都是针对模拟器而言,并非真机).如果启动好了模拟器,且输入adb shell命令后出现error: ...
- "不是内部或外部命令"
问题描述: 使用cmd 运行某个路径下(一般是C:PROGRAM FILES\...或者E:\program files\....或者D:\program files\......下面的某个)的exe ...
- [C#][Windows]]基于ArcFace2.0+红外双目摄像头的活体检测
废话不多说 直接上图 这个是demo中用到的双目摄像头,一个是红外的,一个是正常的rgb摄像头两个usb接口,在电脑上呈现两路摄像头通道程序检测RGB输出图像,当检测到有人脸时,用RGB人脸的位置到红 ...
- QTableWidget自定义表头QHeaderView加全选复选框
1 QTableWidget自定义表头QHeaderView加全选复选框 在使用QTableWidget时需要在表头添加全选复选框,但是默认的表头无法添加复选框,只能用图片画上去一个复 ...
- Unity中sharedMaterials 和 materials
sharedMaterials 和 materials: 这两个属性用法是一样的,但是从效率上来说最好用sharedMaterial,它是共享材质,无论如何操作材质的属性(如更换颜色或者更换shade ...
- JS 日期比较方法
1.日期参数格式:yyyy-mm-dd // a: 日期a, b: 日期b, flag: 返回的结果 function duibi(a, b,flag) { var arr = a.split(&qu ...
- R语言中知识点总结(二)
一些函数不知道什么意思要查,看数值例子,做笔记,知道函数的功能,函数和返回值. 网页上查找关键词,巧用查找(ctrl+F) 数据读取处理,有read.table read R-读取数据(导入csv ...