UVA 10060 A Hole to Catch a Man(求多边形面积相关)
来源:互联网 发布:数据库学哪个好 编辑:程序博客网 时间:2024/05/02 07:17
UVA 10060 A Hole to Catch a Man(求多边形面积相关)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=1001
题意:
给你n个厚度已知的多边形钢板,现在要你融化它们来做成尽量多的(厚度已知)圆形井盖. 问你最多能做成几个?
分析:
本题比较水.
直接求出每个多边形钢板的体积,然后算出体积和sum. 之后输出sum/每个圆形井盖的体积 就是所求.
求多边形的面积用刘汝佳的模板即可.
AC代码:
#include<cstdio>#include<cmath>using namespace std;const double PI=acos(-1.0);const double eps=1e-10;int dcmp(double x){ if(fabs(x)<eps) return 0; return x<0?-1:1;}struct Point{ double x,y; Point(){} Point(double x,double y):x(x),y(y){}}P[1010];typedef Point Vector;Vector operator-(Point A,Point B){ return Vector(A.x-B.x, A.y-B.y);}double Cross(Vector A,Vector B){ return A.x*B.y-A.y*B.x;}double PolygenArea(Point *p,int n){ double area=0; for(int i=1;i<n-1;++i) area += Cross(p[i]-p[0],p[i+1]-p[0]); return fabs(area)/2;}int main(){ int num; while(scanf("%d",&num)==1 && num) { double v=0;//总体积 while(num--) { double thickness;//厚度 int n=0;//当前多边形点数 scanf("%lf",&thickness); scanf("%lf%lf",&P[0].x,&P[0].y); while(++n) { scanf("%lf%lf",&P[n].x,&P[n].y); if(dcmp(P[n].x-P[0].x)==0 && dcmp(P[n].y-P[0].y)==0) break; //上面写成了dcmp(P[n].x-P[0].y)==0 WA了我半天 我擦 } v += PolygenArea(P,n)*thickness; } double r,thick;//圆的半径和厚度 scanf("%lf%lf",&r,&thick); printf("%d\n", (int)( v/(PI*r*r*thick) ) ); } return 0;}
0 0
- UVA 10060 A Hole to Catch a Man(求多边形面积相关)
- UVA 10060 || A hole to catch a man(多边形面积
- UVA 10060 A hole to catch a man
- To be a man
- UVa 11177 Fighting Against a Polygonal Monster 圆与多边形公共面积,二分
- To be a better man
- how to be a man
- to be a better man
- To be a better man
- To be a tough man
- To Be a Dog Man
- to be a better man
- To be a better man
- (beginer)线段求交:多边形面积 UVA 1301 - Fishnet
- poj1584 A Round Peg in a Ground Hole 凸多边形判断 和多边形与圆的位置
- A Round Peg in a Ground Hole(POJ1584点在多边形内+是否为凸多边形)
- POJ-1584-A Round Peg in a Ground Hole-计算几何-凸多边形+多边形包含圆
- 求不规则多边形面积
- 为什么要进行透明计算和透明计算是什么
- HDU 1180 诡异的楼梯
- Linux位置参数变量
- 设计模式 单例模式的缺陷和补救办法及应用场景2
- xcode6模拟器不显示键盘解决方案
- UVA 10060 A Hole to Catch a Man(求多边形面积相关)
- gcc的__attribute__编译属性
- iOS编程必备之Apple产品尺寸大全
- Linux预定义变量
- linux下daemon的认识
- x86, x86-64, i386, IA32, IA64...
- Linux服务器配置——搭建FTP服务器
- Linux接收键盘输入read
- graphlab安装