博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 3301 Texas Trip(几何+三分)
阅读量:5827 次
发布时间:2019-06-18

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

Description

After a day trip with his friend Dick, Harry noticed a strange pattern of tiny holes in the door of his SUV. The local American Tire store sells fiberglass patching material only in square sheets. What is the smallest patch that Harry needs to fix his door?Assume that the holes are points on the integer lattice in the plane. Your job is to find the area of the smallest square that will cover all the holes.

 

Input

The first line of input contains a single integer T expressed in decimal with no leading zeroes, denoting the number of test cases to follow. The subsequent lines of input describe the test cases.Each test case begins with a single line, containing a single integer n expressed in decimal with no leading zeroes, the number of points to follow; each of the following n lines contains two integers x and y, both expressed in decimal with no leading zeroes, giving the coordinates of one of your points.You are guaranteed that T ≤ 30 and that no data set contains more than 30 points. All points in each data set will be no more than 500 units away from (0,0).

 

Output

 

Print, on a single line with two decimal places of precision, the area of the smallest square containing all of your points.

 

 

 

Sample Input

24-1 -11 -11 1-1 1410 110 -1-10 1-10 -1

 

Sample Output

4.00242.00

 

Source

, 2007.7.14
 
这里要知道坐标旋转公式:
如果为旋转前的坐标,为旋转后的坐标,那么有:
 
 
然后对给定的所以点进行旋转,范围为[0,PI/2.0],通过三分搜索找到最小的边长,这里用三分搜索是因为旋转函数是一个单峰函数,然后就可以得出答案了。
 
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 using namespace std;16 int dirx[]={ 0,0,-1,1};17 int diry[]={-1,1,0,0};18 #define PI acos(-1.0)19 #define max(a,b) (a) > (b) ? (a) : (b) 20 #define min(a,b) (a) < (b) ? (a) : (b)21 #define ll long long22 #define eps 1e-1023 #define MOD 100000000724 #define N 3625 #define inf 1<<2626 27 int n;28 struct Node{29 double x,y;30 }node[N];31 double cal(double a){32 double sx=inf;33 double sy=inf;34 double ex=-inf;35 double ey=-inf;36 for(int i=0;i
eps){60 double mid1=(2*low+high)/3;61 double mid2=(low+2*high)/3;62 double ans1=cal(mid1);63 double ans2=cal(mid2);64 if(ans1
View Code

 

你可能感兴趣的文章
CollabNet_Subversion小结
查看>>
mysql定时备份自动上传
查看>>
Linux 高可用集群解决方案
查看>>
17岁时少年决定把海洋洗干净,现在21岁的他做到了
查看>>
linux 启动oracle
查看>>
《写给大忙人看的java se 8》笔记
查看>>
倒计时:计算时间差
查看>>
Linux/windows P2V VMWare ESXi
查看>>
Windows XP倒计时到底意味着什么?
查看>>
tomcat一步步实现反向代理、负载均衡、内存复制
查看>>
运维工程师在干什么学些什么?【致菜鸟】
查看>>
Linux中iptables详解
查看>>
java中回调函数以及关于包装类的Demo
查看>>
maven异常:missing artifact jdk.tools:jar:1.6
查看>>
终端安全求生指南(五)-——日志管理
查看>>
Nginx 使用 openssl 的自签名证书
查看>>
创业维艰、守成不易
查看>>
PHP环境安装套件:快速安装LAMP环境
查看>>
CSS3
查看>>
ul下的li浮动,如何是ul有li的高度
查看>>