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. StringBuilderWriter 这个类需要commons.io.2.6这个包才可以使用, 在maven仓库中搜

  2. Eclipse中使用MySql遇到:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading o

    在Eclipse中使用MySQL遇到了点小问题 如果对Eclipse中配置MySql还有疑问的可以参考一下这篇博客:https://blog.csdn.net/qq_38247544/article/ ...

  3. python模块(3)

    1.xml:实现不同语言或程序之间进行数据交换的协议 <data> <country name="Liechtenstein"> <rank upda ...

  4. Unity 通过代码简单实现文理的灰化显示

    1.可以用于纹理的处理,也可用于模型显示的处理(比如某件准备或者服饰未获取的时候,灰化显示) 线上对比图:                     using System.Collections; ...

  5. Java 访问RabbitMQ

    一.概述 前面学过ActiveMQ.ActiveMQ主要是实现的JMS规范,而RabbitMQ就是AMQP的一个具体实现. RabbitMQ里面有几个概念:生产者.消费者.消息.交换器.路由键.队列. ...

  6. python中socket模块详解

    socket模块简介 网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket.socket通常被叫做"套接字",用于描述IP地址和端口,是一个通信 ...

  7. 日常英语---四、vis.js是什么

    日常英语---四.vis.js是什么 一.总结 一句话总结:A dynamic, browser based visualization library. 动态基于浏览器的可视库 http://vis ...

  8. ubuntu解压和压缩文件

    .tar 解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gun ...

  9. Maven报错Please ensure you are using JDK 1.4 or above and not a JRE解决方法!

    https://www.cnblogs.com/shihua513/p/6163682.html 在eclipse下用maven编译时,很有可能出现以下错误: Please ensure you ar ...

  10. TCHART类型

    private Steema.TeeChart.Styles.Pie pieSeries1; private Steema.TeeChart.Styles.Pie pieSeries2; privat ...