ural 1333 化平面为点计算覆盖率
2013-09-13 10:13
218 查看
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1333
View Code
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; const double eps = 1e-8; const double PI = acos(-1.0); const double INF = 1000000000000000.000; struct Point{ double x,y; Point(double x=0, double y=0) : x(x),y(y){ } //构造函数 }; typedef Point Vector; struct Circle{ Point c; double r; Circle() {} Circle(Point c,double r): c(c),r(r) {} }; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);} Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);} Vector operator * (double p,Vector A){return Vector(A.x*p,A.y*p);} Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){ return a.x < b.x ||( a.x == b.x && a.y < b.y); } int dcmp(double x){ if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; } bool operator == (const Point& a, const Point& b){ return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0; } ///向量(x,y)的极角用atan2(y,x); inline double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; } inline double Length(Vector A) { return sqrt(Dot(A,A)); } inline double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); } double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; } Point read_point(){ Point A; scanf("%lf %lf",&A.x,&A.y); return A; } /*************************************分 割 线*****************************************/ const int maxn = 15; Circle C[maxn]; int main() { //freopen("E:\\acm\\input.txt","r",stdin); int N; cin>>N; for(int i=1;i<=N;i++){ scanf("%lf %lf %lf",&C[i].c.x,&C[i].c.y,&C[i].r); } double cnt = 0; for(double x = 0.000;x<=1.000;x+=0.001) for(double y = 0.000;y<=1.000;y+=0.001){ Point A = Point(x,y); for(int i=1;i<=N;i++){ if(dcmp(Length(A-C[i].c)-C[i].r) < 0){ cnt ++; break; } } } double prec = cnt/1e6; cout<<prec*100<<endl; }
View Code
相关文章推荐
- 【解题报告】 URAL 1333 Genie Bomber 2 -- 利用类似统计的方法计算覆盖效率
- Ural-1020. Rope(简单计算几何)
- C语言平面几何2-距离、长度、模的计算
- Android 单元测试覆盖率计算
- URAL 1333
- 计算几何模板补充(三维空间体积、平面、直线、向量相关计算。附上hdu4741,求异面直线的最短距离与交点)
- 在一个平面坐标系上,有两个矩形,计算交集的面积。
- Ural 1971(Graphics Settings-延迟计算)
- 计算空间点到平面的投影点坐标(代码)
- URAL 1207 || Median on the Plane(将平面偶数点集均分
- 挑战程序设计竞赛 3.6 与平面和空间打交道的计算几何
- 设计Point类用来定义平面上的一个点,用构造方法传 递坐标位置,方法有计算两点的距离。编写测试类,在该类中实现Point类的对象。
- 三角平面法向的计算方式
- URAL 1963 Kite 计算几何
- URAL 1141 计算模n的e次根
- (datastructure1.5.1)URAL 1068 SUM(计算前n项和)
- DirectX 9的一些数学计算函数:平面
- Ural_1348. Goat in the Garden 2(计算几何)
- 利用minAreaRect计算平面矩形的旋转角度
- 平面方程拟合计算