UVA 10060 A hole to catch a man

这题。。。读懂就很水了。

 

给你一些钢板的形状(凸凹不限),还有厚度,给你圆井盖的半径和厚度,问你可以覆盖掉多少个井。

 

直接求面积求体积除下就好了,没啥好说的。。

 

#include <queue> #include <stack> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <iostream> #include <limits.h> #include <string.h> #include <string> #include <algorithm> using namespace std; const int MAX = 1010; const double pi = acos(-1); struct point{ double x,y;}; const double eps = 1e-6; bool dy(double x,double y) { return x > y + eps;} // x > y bool xy(double x,double y) { return x < y - eps;} // x < y bool dyd(double x,double y) { return x > y - eps;} // x >= y bool xyd(double x,double y) { return x < y + eps;} // x <= y bool dd(double x,double y) { return fabs( x - y ) < eps;} // x == y point p[MAX]; double area_polygon(point p[],int n) { double s = 0.0; for(int i=0; i<n; i++) s += p[(i+1)%n].y * p[i].x - p[(i+1)%n].x * p[i].y; return fabs(s)/2.0; } int main() { int n; double v,tt,r,t; while( ~scanf("%d",&n) && n ) { v = 0; while( n-- ) { scanf("%lf",&t); scanf("%lf%lf",&p[0].x,&p[0].y); int m = 0; do { m++; scanf("%lf%lf",&p[m].x,&p[m].y); }while( !(dd(p[m].x,p[0].x) && dd(p[m].y,p[0].y)) ); v += area_polygon(p,m)*t; } scanf("%lf%lf",&r,&tt); int ans = (int)(v/(pi*r*r*tt)); printf("%d/n",ans); } return 0; }  

你可能感兴趣的:(UVA 10060 A hole to catch a man)