ural 1333 化平面为点计算覆盖率

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1333

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point{
double x,y;
Point(double x=, double y=) : 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 ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(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 = ;
Circle C[maxn]; int main()
{
//freopen("E:\\acm\\input.txt","r",stdin); int N;
cin>>N;
for(int i=;i<=N;i++){
scanf("%lf %lf %lf",&C[i].c.x,&C[i].c.y,&C[i].r);
} double cnt = ;
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=;i<=N;i++){
if(dcmp(Length(A-C[i].c)-C[i].r) < ){
cnt ++;
break;
}
}
}
double prec = cnt/1e6; cout<<prec*<<endl;
}
上一篇:DataBinding


下一篇:crontab 定时任务 每过多少分钟执行