EOJ 1058. 挤模具 (多边形面积)
题目链接: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. 挤模具 (多边形面积)的更多相关文章
- EOJ 1127. 多边形面积(计算几何)
题目链接:1127. 多边形面积(计算几何) 题意 按逆时针顺序给出 \(n\) 个点的坐标,求这些点围成的多边形的面积. 思路 选择多边形上的一个点,然后每次枚举之后的两个点,计算叉积,注意要保留符 ...
- [知识点]计算几何I——基础知识与多边形面积
// 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...
- 简单几何(向量旋转+凸包+多边形面积) UVA 10652 Board Wrapping
题目传送门 题意:告诉若干个矩形的信息,问他们在凸多边形中所占的面积比例 分析:训练指南P272,矩形面积长*宽,只要计算出所有的点,用凸包后再求多边形面积.已知矩形的中心,向量在原点参考点再旋转,角 ...
- 三角剖分求多边形面积的交 HDU3060
//三角剖分求多边形面积的交 HDU3060 #include <iostream> #include <cstdio> #include <cstring> #i ...
- CF 107E 多边形面积并
107E Darts 题目:给出n个矩形,问落在n个矩形交的部分的概率 分析:裸的多边形面积并. 代码略..
- POJ1265——Area(Pick定理+多边形面积)
Area DescriptionBeing well known for its highly innovative products, Merck would definitely be a goo ...
- poj 1654 Area 多边形面积
/* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...
- [ECNU 1624] 求交集多边形面积
求交集多边形面积 Time Limit:1000MS Memory Limit:30000KB Total Submit:98 Accepted:42 Description 在平面上有两给定的凸多边 ...
- Area - POJ 1654(求多边形面积)
题目大意:从原点开始,1-4分别代表,向右下走,向右走,向右上走,向下走,5代表回到原点,6-9代表,向上走,向左下走,向左走,向左上走.求出最后的多边形面积. 分析:这个多边形面积很明显是不规则的, ...
随机推荐
- 开源 NAS 操作系统不完全汇总
市面上能见到的 NAS 操作系统很多,有如 FreeNAS 这样意气风发的开源免费版,也有完全商业的闭源版本,更有如黑群晖之类的破解版本.NAS 系统的迭代是一个大浪淘沙的过程,活下来的系统在功能上逐 ...
- JQuery实现页面跳转
$(function(){ var pn = $("#gotopagenum").val(); //#gotopagenum是文本框的id属性 location.hre ...
- [ERR] 1114 - The table 'xxx' is full
异常原因: 磁盘空间不足 解决办法: 1. 新增磁盘 2. 删除无用数据 信息补充: df: df -h #查询磁盘空间命令 du: du|sort -nr|more #显示目录或者文件所占空间 du ...
- windows 虚拟内存查看
- 【转】modulenotfounderror: no module named 'matplotlib._path'问题的解决
今天在装matplotlib包的时候遇到这样的问题,在网上找了很长时间没有类似很好的解决方法,最后自己 研究找到了解决的方法. 之前在pycharm里面已经装了matplotlib包,之后觉着下载包挺 ...
- 批量授一种权限给用户程序 plm enovia
set context user DanielDai;add program LUX_UserAssignment java execute immediate code 'import com.ma ...
- 试试监听输入框的值 (eq:在未输入前,按钮为灰色,输入内容后,按钮变蓝色)
参考网址:https://blog.csdn.net/tel13259437538/article/details/78927071
- .net Core在过滤器中获取 系统接口方法(以IMemoryCache 为例) 及HttpContext 获取系统接口
public Class SysActionAttribute :Attribute, IActionFilter // Attribute 用于控制器中 特性控制,当在控制器或控 ...
- Django版本更新(升级)到指定版本的命令
- 怎么更新 WIN10里的SMBv1协议
控制面板 ---启用或关闭Windows功能---打开SMBv1服务: