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的更多相关文章

  1. LightOJ 1203 Guarding Bananas (凸包最小顶角)

    题目链接:LightOJ 1203 Problem Description Once there was a lazy monkey in a forest. But he loved banana ...

  2. LightOj1203 - Guarding Bananas(凸包求多边形中的最小角)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1203 题意:给你一个点集,求凸包中最小的角:模板题,但是刚开始的时候模板带错了,错的我 ...

  3. LightOJ 1203--Guarding Bananas(二维凸包+内角计算)

    1203 - Guarding Bananas    PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 M ...

  4. Soldier and Bananas

    Soldier and Bananas 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=173141 题意: 给 ...

  5. CodeForces 546A-Soldier and Bananas

    题意: 有n dollar,the first banana cost  k dollars,第i个就需cost k*i,问买w个bananas是否需要借钱:借钱需要多少? 分析:首先计算w个bana ...

  6. BZOJ 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场

    题目 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 491  S ...

  7. 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场

    1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 498  Solve ...

  8. [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 ...

  9. 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 ...

随机推荐

  1. 运行python脚本后台执行

    最近搞到了一台服务器,挂一个脚本刷刷河畔在线时间.脚本随便写了两下,能跑到什么时候就随缘了 https://blog.csdn.net/philosophyatmath/article/details ...

  2. template-web.js 引用变量、函数

    1.关键字   $imports.+变量/函数 {{if $imports.myParseInt(b.health_money)}} <span class="num"> ...

  3. _itemmod_enchant_groups

    随机附魔组 附魔组 `groupId` 分组编号,同一groupId的附魔效果被随机抽取 `enchantId` 附魔Id 对应SpellItemEnchantment.dbc `chance` 被抽 ...

  4. BZOJ 3878 【AHOI2014】 奇怪的计算器

    题目链接:奇怪的计算器 如果没有溢出的话,所有的标记都可以在线段树上直接维护,所以一棵线段树就解决问题了. 现在有了溢出,怎么办呢? 发现就算溢出了,各个元素的相对大小关系也是不变的.所以,如果一开始 ...

  5. Ubuntu18.04的网络配置

    网卡与DNS配置 1)打开命令窗口(右键单机桌面选择Open Terminal或者用快捷键Ctrl+Alt+T打开终端),输入ip a查看自己的网卡编号 2)输入命令sudo vim /etc/net ...

  6. 1.0 poi单元格合合并及写入

    最近项目中用到poi生成Excel时,用到了单元格合并,于是参考了http://www.anyrt.com/blog/list/poiexcel.html写的文章,但是其中有些地方不是很清楚,于是自己 ...

  7. 史上最全Java面试题(带全部答案)

    今天要谈的主题是关于求职,求职是在每个技术人员的生涯中都要经历多次.对于我们大部分人而言,在进入自己心仪的公司之前少不了准备工作,有一份全面细致面试题将帮助我们减少许多麻烦.在跳槽季来临之前,特地做这 ...

  8. leecode第五十四题(螺旋矩阵)

    class Solution { public: vector<int> spiralOrder(vector<vector<int>>& matrix) ...

  9. redux与redux-react使用示例

    redux使用 <script type="text/babel"> var Counter=React.createClass({ incrementIfOdd:fu ...

  10. Android DatePickerDialog 使用方法

    (一)在Android 4.0以上系统的某些手机(如本人的测试机红米Note(系统4.4.4),以及模拟器(系统4.0)),使用如下代码创建时间选择器时,页面效果如图: Calendar cal = ...