在古老的迈瑞城,巍然屹立着 n 块神石。长老们商议,选取 3 块神石围成一个神坛。因为神坛的能量强度与它的面积成反比,因此神坛的面积越小越好。特殊地,如果有两块神石坐标相同,或者三块神石共线,神坛的面积为 0.000

长老们发现这个问题没有那么简单,于是委托你编程解决这个难题。

输入格式:

输入在第一行给出一个正整数 n(3 ≤ n ≤ 5000)。随后 n 行,每行有两个整数,分别表示神石的横坐标、纵坐标(− 横坐标、纵坐标 <)。

输出格式:

在一行中输出神坛的最小面积,四舍五入保留 3 位小数。

输入样例:

8
3 4
2 4
1 1
4 1
0 3
3 0
1 3
4 2

输出样例:

0.500

样例解释

输出的数值等于图中红色或紫色框线的三角形的面积。

第一次接触计算几何的题目

先算出两两边的向量  再把向量按照极角来排序    然后用叉乘法一一求面积 更新最小值

#include<bits/stdc++.h>
using namespace std;
//input by bxd
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i>=(b);i--)
#define RI(n) scanf("%d",&(n))
#define RII(n,m) scanf("%d%d",&n,&m)
#define RIII(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define RS(s) scanf("%s",s);
#define LL long long
#define pb push_back
#define fi first
#define REP(i,N) for(int i=0;i<(N);i++)
#define CLR(A,v) memset(A,v,sizeof A)
///////////////////////////////////
#define inf 0x3f3f3f3f
#define N 50010
int n; struct node{
long long x,y;
}p[N],temp[N];
bool cmp(node a,node b) {
return b.y*a.x>a.y*b.x;
}
int main() {
scanf("%d",&n);
for(int i=;i<=n;i++) {
scanf("%lld %lld",&p[i].x,&p[i].y);
}
double ans=pow(,)/;
for(int i=;i<=n;i++) {
int t=;
for(int j=;j<=n;j++) {
if(i==j) continue;
temp[t].x=p[j].x-p[i].x;
temp[t].y=p[j].y-p[i].y;
t++;
}
sort(temp+,temp+t,cmp);
for(int j=;j<t-;j++){
ans=min(ans,(temp[j].x*temp[j+].y-temp[j+].x*temp[j].y)*0.5);
}
}
printf("%.3f",ans);
return ;
}

L3-021 神坛 (30 分) 计算几何的更多相关文章

  1. PTA 07-图5 Saving James Bond - Hard Version (30分)

    07-图5 Saving James Bond - Hard Version   (30分) This time let us consider the situation in the movie ...

  2. PTA 社交网络图中结点的“重要性”计算(30 分)

    7-12 社交网络图中结点的“重要性”计算(30 分) 在社交网络中,个人或单位(结点)之间通过某些关系(边)联系起来.他们受到这些关系的影响,这种影响可以理解为网络中相互连接的结点之间蔓延的一种相互 ...

  3. L3-015 球队“食物链” (30 分)

    L3-015 球队“食物链” (30 分)   某国的足球联赛中有N支参赛球队,编号从1至N.联赛采用主客场双循环赛制,参赛球队两两之间在双方主场各赛一场. 联赛战罢,结果已经尘埃落定.此时,联赛主席 ...

  4. PAT A1127 ZigZagging on a Tree (30 分)——二叉树,建树,层序遍历

    Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can ...

  5. 04-树6 Complete Binary Search Tree(30 分)

    title: 04-树6 Complete Binary Search Tree(30 分) date: 2017-11-12 14:20:46 tags: - 完全二叉树 - 二叉搜索树 categ ...

  6. PTA 7-2 二叉搜索树的结构(30 分)

    7-2 二叉搜索树的结构(30 分) 二叉搜索树或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值:若它的右子树不空,则右子树上所有结点的值均大 ...

  7. 1127 ZigZagging on a Tree (30 分)

    1127 ZigZagging on a Tree (30 分) Suppose that all the keys in a binary tree are distinct positive in ...

  8. 【PAT】1053 Path of Equal Weight(30 分)

    1053 Path of Equal Weight(30 分) Given a non-empty tree with root R, and with weight W​i​​ assigned t ...

  9. 【PAT】1091 Acute Stroke(30 分)

    1091 Acute Stroke(30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the s ...

随机推荐

  1. <转载>bellman-ford算法

    转载来源:https://www.cnblogs.com/tanky_woo/archive/2011/01/17/1937728.html 相关文章: 1.Dijkstra算法: http://ww ...

  2. Day6------------软连接和硬链接

    一.块 1.操作系统分四大类块 super block 掌管全局 inode block directory block block 2.删文件 普通删除只是删除链接,数据还在硬盘 彻底删除:覆盖操作 ...

  3. a href=#与 a href=javascript:void(0) 的区别(转)

    a href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP <a href="javascript:void(0)" onCl ...

  4. python自动化-unittest批量执行用例(discover)

    前言 我们在写用例的时候,单个脚本的用例好执行,那么多个脚本的时候,如何批量执行呢?这时候就需要用到unittet里面的discover方法来加载用例了. 加载用例后,用unittest里面的Text ...

  5. npm常用模块

    https://blog.csdn.net/heliumlau/article/details/70577727

  6. Saruman's Army(POJ3069)

    Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. ...

  7. 【mysql】编码问题

    原始数据是unicode,存入数据库.需要注意的几个地方: 1.建立数据库时,选择编码方式为utf8 -- UTF-8 Unicode 2.代码中建立数据库连接时,选择charset=utf8 3.存 ...

  8. cf1107d 映射关系

    #include<bits/stdc++.h> using namespace std; ][]; int judge(int i){ ;j<=n;j++) ][j]); ; } i ...

  9. idea导入java项目

    https://blog.csdn.net/m0_37106742/article/details/70154244 ( 主要 )https://blog.csdn.net/u012099869/ar ...

  10. Linux进程管理工具

    Linux进程管理工具 Htop yum install htop 参考帮助: http://blog.csdn.net/skh2015java/article/details/53173896 Li ...