●POJ 3348 Cows
题链:
http://poj.org/problem?id=3348
题解:
计算几何,凸包,多边形面积
好吧,就是个裸题,没什么可讲的。
代码:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define MAXN 10050
using namespace std;
const double eps=1e-8;
int sign(double x){
if(fabs(x)<=eps) return 0;
return x<0?-1:1;
}
struct Point{
double x,y;
Point(double _x=0,double _y=0):x(_x),y(_y){}
void Read(){scanf("%lf%lf",&x,&y);}
};
typedef Point Vector;
bool operator < (Point A,Point B){return sign(A.x-B.x)<0||(sign(A.x-B.x)==0&&sign(A.y-B.y)<0);}
bool operator == (Point A,Point B){return sign(A.x-B.x)==0&&sign(A.y-B.y)==0;}
Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}
double operator ^ (Vector A,Vector B){return A.x*B.y-A.y*B.x;}
Point D[MAXN],H[MAXN];
int Andrew(int dnt){
int hnt=0,k=0;
sort(D+1,D+dnt+1);
dnt=unique(D+1,D+dnt+1)-D-1;
for(int i=1;i<=dnt;i++){
while(hnt>1&&sign((H[hnt]-H[hnt-1])^(D[i]-H[hnt-1]))<=0) hnt--;
H[++hnt]=D[i];
} k=hnt;
for(int i=dnt-1;i>=1;i--){
while(hnt>k&&sign((H[hnt]-H[hnt-1])^(D[i]-H[hnt-1]))<=0) hnt--;
H[++hnt]=D[i];
}
return hnt;
}
double GCPA(int hnt){//Get_Convex_Polygon_Area
double S=0;
for(int i=1;i<hnt;i++) S+=(H[i]^H[i+1])/2;
return S;
}
int main(){
int N; scanf("%d",&N);
for(int i=1;i<=N;i++) D[i].Read();
printf("%d",(int)(GCPA(Andrew(N))/50));
return 0;
}
●POJ 3348 Cows的更多相关文章
- POJ 3348 - Cows 凸包面积
求凸包面积.求结果后不用加绝对值,这是BBS()排序决定的. //Ps 熟练了template <class T>之后用起来真心方便= = //POJ 3348 //凸包面积 //1A 2 ...
- POJ 3348 Cows 凸包 求面积
LINK 题意:给出点集,求凸包的面积 思路:主要是求面积的考察,固定一个点顺序枚举两个点叉积求三角形面积和除2即可 /** @Date : 2017-07-19 16:07:11 * @FileNa ...
- POJ 3348 Cows [凸包 面积]
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9022 Accepted: 3992 Description ...
- 2018.07.03 POJ 3348 Cows(凸包)
Cows Time Limit: 2000MS Memory Limit: 65536K Description Your friend to the south is interested in b ...
- poj 3348:Cows(计算几何,求凸包面积)
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6199 Accepted: 2822 Description ...
- poj 3348 Cows 凸包 求多边形面积 计算几何 难度:0 Source:CCC207
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7038 Accepted: 3242 Description ...
- POJ 3348 Cows(凸包+多边形面积)
Description Your friend to the south is interested in building fences and turning plowshares into sw ...
- POJ 3348 Cows (凸包模板+凸包面积)
Description Your friend to the south is interested in building fences and turning plowshares into sw ...
- 简单几何(凸包+多边形面积) POJ 3348 Cows
题目传送门 题意:求凸包 + (int)求面积 / 50 /************************************************ * Author :Running_Tim ...
随机推荐
- Flask 学习 五 电子邮件
pip install mail from flask_mail import Mail # 邮件配置 app.config['MAIL_SERVER']='smtp.qq.com' app.conf ...
- sqlserver之排序规则和ETL不支持sqlserverdatetime2的问题
sqlserver的排序规则大概分为Windows 排序规则和 SQL Server 排序规则.数据在安装的时候,默认不设置会默认为SQL_Latin1_General_CP1_CI_AI.数据库在创 ...
- Something about SeekingJob---TelInterview(电话面试)
昨天和今天分别收到两次电话面试,有一点小小感悟,遂注之. 作为一枚还未毕业的大三狗来说,我在想,找个实习真的是西天取金,必定要先经历九九八十一难吗(伤心)?所以在这里整理了电话面试遇到的问题: 集合框 ...
- nodeJs多进程Cluster
在前端页面中,如果我们想进行多进程,我们会用到WebWorker,而在NodeJs中,我们如果想充分利用服务器核心资源,我们会用到Node中Cluster模块 直接上代码吧: const cluste ...
- python的命名空间
Python的命名空间是Python程序猿必须了解的内容,对Python命名空间的学习,将使我们在本质上掌握一些Python中的琐碎的规则. 接下来我将分四部分揭示Python命名空间的本质:一.命名 ...
- VMware网络配置
NAT模式 首先保证虚拟机网卡和主机对接,虚拟机网络连接要和主机在同一网段 1. 控制面板\网络和 Internet\网络连接中配置VMnet8 2. 编辑虚拟机网络配置 此处子网ip需要和Vnet8 ...
- Angular 学习笔记 ( CDK - Layout )
简单说就是 js 的 media query. 1. BreakpointObserver const layoutChanges = this.breakpointObserver.observe ...
- spring-oauth-server实践:access_token的有效期分析
1.access_token有效期检查 用expiration和new Date()比较!!!!!! 分析目标-->expiration什么时候设置,设置规则如何配置!!!!!!! 2.acce ...
- python入门(4)第一个python程序
python入门(4)第一个python程序 在交互式环境的提示符>>>下,直接输入代码,按回车,就可以立刻得到代码执行结果.现在,试试输入100+200,看看计算结果是不是300: ...
- maven快速下载jar镜像
<!--国内镜像--><mirror> <id>CN</id> <name>OSChina Central</name> ...