●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 ...
随机推荐
- 冲刺NO.8
Alpha冲刺第八天 站立式会议 项目进展 项目稳步进行,项目的基础部分如基本信息管理,信用信息管理等部分已相对比较完善. 问题困难 技术困难在短期内很难发生质的变化,而本项目由于选择了队员不太熟悉的 ...
- android 广播,manifest.xml注册,代码编写
1.种 private void downloadBr(File file) { // 广播出去,由广播接收器来处理下载完成的文件 Intent sendIntent = new Intent ...
- mysql基础篇 - 其他基本操作
基础篇 - 其他基本操作 其他基本操作 一.实验简介 本节实验中我们将学习并实践数据库的其他基本操作:索引.视图,导入和导出,备份和恢复等. 这些概念对于数据库管理员而言都非常重要,请 ...
- segmentedControl设置字体和字体颜色问题
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],UITextAttributeT ...
- pymysql 多字段插入
d = {'name':'alx','age':18,'pp':11,'cc':12} sql = '''insert into xx(%s) value(%s)''' key_list = [] v ...
- DML数据操作语言之增加,删除,更新
1.数据的增加 数据的增加要用到insert语句 ,基本格式是: insert into <表名> (列名1,列名2,列名3,......) values (值1,值2,值3,..... ...
- bzoj千题计划217:bzoj2333: [SCOI2011]棘手的操作
http://www.lydsy.com/JudgeOnline/problem.php?id=2333 读入所有数据,先模拟一遍所有的合并操作 我们不关心联通块长什么样,只关心联通块内有谁 所以可以 ...
- hp MSA50 5盘RAID5重建为4盘RAID5怎么恢复数据
[用户单位] XX省电视台[数据恢复故障描述] 一台HP 服务器,挂接一台HP MSA50磁盘阵列,内接5块1TB硬盘,原先结构为RAID5. 使用一段时间后,其中一块硬盘掉线,因RAID5支持一块硬 ...
- kafka安装使用和遇到的坑
下载安装 参考:https://segmentfault.com/a/1190000012730949 https://kafka.apache.org/quickstart 关闭服务 关闭zoo ...
- Linux实用的网站
ABCDOCKER网站 https://www.abcdocker.com/ 徐亮伟网站 http://www.xuliangwei.com/ 安装centos物理服务 ...