题目链接:1058. 挤模具

题意

给出模具的底和体积,求模具的高。

思路

模具的底为多边形,因此求出多边形面积,用体积除以底的面积就是答案。

多边形的面积求解见 EOJ 1127. 多边形面积(计算几何)

代码

#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 100 + 10; inline int dcmp(db x) {
if(fabs(x) < eps) return 0;
return x > 0? 1: -1;
} class Point {
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
void input() {
scanf("%lf%lf", &x, &y);
}
bool operator<(const Point &a) const {
return (!dcmp(x - a.x))? dcmp(y - a.y) < 0: x < a.x;
}
bool operator==(const Point &a) const {
return dcmp(x - a.x) == 0 && dcmp(y - a.y) == 0;
}
db dis2(const Point a) {
return pow(x - a.x, 2) + pow(y - a.y, 2);
}
db dis(const Point a) {
return sqrt(dis2(a));
}
db dis2() {
return x * x + y * y;
}
db dis() {
return sqrt(dis2());
}
Point operator+(const Point a) {
return Point(x + a.x, y + a.y);
}
Point operator-(const Point a) {
return Point(x - a.x, y - a.y);
}
Point operator*(double p) {
return Point(x * p, y * p);
}
Point operator/(double p) {
return Point(x / p, y / p);
}
db dot(const Point a) {
return x * a.x + y * a.y;
}
db cross(const Point a) {
return x * a.y - y * a.x;
}
}; Point p[maxn]; int n; db area() {
if(n < 3) return 0.0;
db ans = 0.0;
for(int i = 2; i < n; ++i) {
ans += (p[i] - p[1]).cross(p[i + 1] - p[1]);
}
return ans * 0.5;
} int main() {
while(~scanf("%d", &n) && n) {
db s = 0;
db v;
for(int i = 1; i <= n; ++i) {
p[i].input();
}
scanf("%lf", &v);
s = area();
printf("BAR LENGTH: %.2lf\n", v / fabs(s));
}
return 0;
}

EOJ 1058. 挤模具 (多边形面积)的更多相关文章

  1. EOJ 1127. 多边形面积(计算几何)

    题目链接:1127. 多边形面积(计算几何) 题意 按逆时针顺序给出 \(n\) 个点的坐标,求这些点围成的多边形的面积. 思路 选择多边形上的一个点,然后每次枚举之后的两个点,计算叉积,注意要保留符 ...

  2. [知识点]计算几何I——基础知识与多边形面积

    // 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...

  3. 简单几何(向量旋转+凸包+多边形面积) UVA 10652 Board Wrapping

    题目传送门 题意:告诉若干个矩形的信息,问他们在凸多边形中所占的面积比例 分析:训练指南P272,矩形面积长*宽,只要计算出所有的点,用凸包后再求多边形面积.已知矩形的中心,向量在原点参考点再旋转,角 ...

  4. 三角剖分求多边形面积的交 HDU3060

    //三角剖分求多边形面积的交 HDU3060 #include <iostream> #include <cstdio> #include <cstring> #i ...

  5. CF 107E 多边形面积并

    107E Darts 题目:给出n个矩形,问落在n个矩形交的部分的概率 分析:裸的多边形面积并. 代码略..

  6. POJ1265——Area(Pick定理+多边形面积)

    Area DescriptionBeing well known for its highly innovative products, Merck would definitely be a goo ...

  7. poj 1654 Area 多边形面积

    /* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...

  8. [ECNU 1624] 求交集多边形面积

    求交集多边形面积 Time Limit:1000MS Memory Limit:30000KB Total Submit:98 Accepted:42 Description 在平面上有两给定的凸多边 ...

  9. Area - POJ 1654(求多边形面积)

    题目大意:从原点开始,1-4分别代表,向右下走,向右走,向右上走,向下走,5代表回到原点,6-9代表,向上走,向左下走,向左走,向左上走.求出最后的多边形面积. 分析:这个多边形面积很明显是不规则的, ...

随机推荐

  1. 基于Java Agent的premain方式实现方法耗时监控(转),为了找到结论执行:premain在jvm启动的时候执行,所有方法前,会执行MyAgent的premain方法

    Java Agent是依附于java应用程序并能对其字节码做相关更改的一项技术,它也是一个Jar包,但并不能独立运行,有点像寄生虫的感觉.当今的许多开源工具尤其是监控和诊断工具,很多都是基于Java ...

  2. 从0开始的InfiniBand硬件踩坑过程

    由于科学计算实验的需求,需要使用InfiniBand做一个持久性内存全互联的分布式存储系统.其中从网卡到交换机使用Mellanox全家桶,而在Mellanox网卡与交换机的使用过程中还是遇到了不少的问 ...

  3. 带有headers的urllib库爬取

    #请求头 #1.引入模块 from urllib import request #2.操作 #(1)定义目标url base_url = "http://www.langlang2017.c ...

  4. 首次使用Git将码云上的代码Clone至本地

    使用Git将码云上的代码Clone至本地 1. 安装Git https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-G ...

  5. string(81) "SQLSTATE[HY000]: General error: 1364 Field 'content' doesn't have a default value"

    mysql版本是5.7.26,在插入数据时报错: string(81) "SQLSTATE[HY000]: General error: 1364 Field 'content' doesn ...

  6. iOS 点击按钮截屏

    @interface CaptureViewController () @property (nonatomic, strong) UIImageView *backgrounView; //控制器背 ...

  7. 2019-9-29-dotnet-对-DateTime-排序

    title author date CreateTime categories dotnet 对 DateTime 排序 lindexi 2019-09-29 14:55:49 +0800 2019- ...

  8. go语言从例子开始之Example13.函数多返回值

    Go 内建多返回值 支持.这个特性在 Go 语言中经常被用到,例如用来同时返回一个函数的结果和错误信息. Example: package main import "fmt" // ...

  9. [HTML知识体系]meta标签的常见用法

    1.meta是什么 元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词. 标签位于文档的头部,不包含任何内容. 标签的属性定义了与文档相关联的名称 ...

  10. 使用IntelliJ IDEA 15和Maven创建Java Web项目(转)

    转自:https://blog.csdn.net/myarrow/article/details/50824793 1. Maven简介 相对于传统的项目,Maven 下管理和构建的项目真的非常好用和 ...