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. POJ 3279 Fliptile(翻格子)

    POJ 3279 Fliptile(翻格子) Time Limit: 2000MS    Memory Limit: 65536K Description - 题目描述 Farmer John kno ...

  2. 复习ing

    记不住啊,我能有什么办法,只好一遍又一遍看

  3. windows特殊文件或文件夹

    考了很多文章,搜集了很多资料整理而成.好的用途可以用来隐藏个人资料,防止误删,病毒免疫等等.至于坏的方面,当然也可用来隐藏木马等等,就看你怎么用了.还有一个没有搞明白,资料上也没找到,请知道的指点一下 ...

  4. 2017-2018-2 20165306 实验四《Android开发基础》实验报告

    实验四<Android开发基础>实验报告 实验报告封面 实验内容 Android程序设计-1 实验要求: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java ...

  5. 51nod 1689 逛街(优先队列)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1689 题意: 题意: 枚举终点,这样就确定路上的花费,接下来只需要计算进 ...

  6. xdg-open命令智能打开各种格式的文件

    在linux中,通常用命令行打开文本文件,比如用命令gedit.more.cat.vim.less.但当需要打开其他格式文件时,比如pdf.jpg.mp3格式文件,咱们通常做法是进入到文件所在的目录, ...

  7. Codeforces 785 D. Anton and School - 2

    题目链接:http://codeforces.com/contest/785/problem/D 我们可以枚举分界点,易知分界点左边和右边分别有多少个左括号和右括号,为了不计算重复我们强制要求选择分界 ...

  8. 下载安装tomcat和jdk,配置运行环境,与Intellij idea 2017关联

    第一篇博客,最近公司要用java和jsp开发新的项目,第一次使用Intellij idea 2017,有很多地方需要一步步配置,有些按照网上的教程很快就配置好了,有的还是琢磨了一会儿,在这里做一个记录 ...

  9. Android Studio 使用USB真机调试教程

    允许安装未知来源的软件 允许USB调试 设置启动方式 选择USB device 然后运行 会自动安装软件启动! 参考: https://blog.csdn.net/fubo1990/article/d ...

  10. selenium 在电脑浏览器中用手机模式打开

    import requests from selenium import webdriver from selenium.webdriver.common.action_chains import A ...