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;
}
ural 1333 化平面为点计算覆盖率的更多相关文章
- ural 1333 Genie Bomber 2
#include <cstdio> #include <cstring> #include <algorithm> #define maxn 200 using n ...
- kubernetes 降本增效标准指南| 容器化计算资源利用率现象剖析
作者:詹雪娇,腾讯云容器产品经理,目前主要负责腾讯云集群运维中心的产品工作. 张鹏,腾讯云容器产品工程师,拥有多年云原生项目开发落地经验.目前主要负责腾讯云TKE集群和运维中心开发工作. 引言 降本增 ...
- 最小发射功率下WSN的连通性和覆盖率
简述: 实验要求我们将传感器节点随机均匀分布在1x1的方格中,然后计算节点的最小共同发射功率(COMPOW),保证网络刚好连通,并计算出这些节点的覆盖率.为了解决这个问题,我们的做法是随机均匀部署10 ...
- Sonar + Jacoco,强悍的UT, IT 双覆盖率统计(转)
以前做统计代码测试覆盖,一般用Cobertura.以前统计测试覆盖率,一般只算Unit Test,或者闭上眼睛把Unit Test和Integration Test一起算. 但是,我们已经过了迷信UT ...
- 浅析 JavaScript 中的 函数 currying 柯里化
原文:浅析 JavaScript 中的 函数 currying 柯里化 何为Curry化/柯里化? curry化来源与数学家 Haskell Curry的名字 (编程语言 Haskell也是以他的名字 ...
- 用 Cobertura 测量测试覆盖率
尽管测试先行编程(test-first programming)和单元测试已不能算是新概念,但测试驱动的开发仍然是过去 10 年中最重要的编程创新.最好的一些编程人员在过去半个世纪中一直在使用这些 ...
- 记忆化搜索 P1464 Function
题目描述 对于一个递归函数w(a,b,c) 如果a≤0 or b≤0 or c≤0就返回值1. 如果a>20 or b>20 or c>20就返回w(20,20,20) 如果a< ...
- JS中的柯里化(currying)
何为Curry化/柯里化? curry化来源与数学家 Haskell Curry的名字 (编程语言 Haskell也是以他的名字命名). 柯里化通常也称部分求值,其含义是给函数分步传递参数,每次传递参 ...
- 两矩阵各向量余弦相似度计算操作向量化.md
余弦相似度计算: \cos(\bf{v_1}, \bf{v_2}) = \frac{\left( v_1 \times v_2 \right)}{||v_1|| * ||v_2|| } \cos(\b ...
随机推荐
- Oracle计算时间函数(numtodsinterval、numtoyminterval)
numtodsinterval(<x>,<c>) ,x是一个数字,c是一个字符串,表明x的单位,这个函数把x转为interval day to second数据类型 常用的单位 ...
- ios专题 - 使用bundle文件管理资源
[原创]http://www.cnblogs.com/luoguoqiang1985 以前,自己写程序,图片等资源放得比较乱.后来,发现有个更好的方法来管理图片等资源文件 --bundle文件. 1) ...
- DisUnity——Unity3D反编译资源提取利刃
1.资源 软件及项目源码地址:https://github.com/ata4/disunity/releases 2.使用方法: 将待反编译的文件放入文件夹中:如:E:\Demo\ 在disunity ...
- Linux 下的 blog客户端
apt-cahce search metaweblog found gnome-blog blogilo try blogilo
- gnome中文翻译之po
文件类型: po: 用msginit分析pot文件,生成各语言对应的po文件,比如中文的zh_CN.po. mo: 用msgfmt将po文件编译生成mo文件,这是二进制文件,不能直接编辑. gmo: ...
- [CSS]文本属性(Text)
CSS 文本属性(Text) 属性 描述 CSS color 设置文本的颜色. 1 direction 规定文本的方向 / 书写方向. 2 letter-spacing 设置字符间距. 1 lin ...
- 简单python2.7.3安装setuptools模块
下载setuptools https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg 安装 .6c11- ...
- 2016021801 - Java内存区域归纳对比
线程私有 线程共享 程序计数器,虚拟机栈,本地方法栈 堆,方法区 内存区 异常 异常原因 程序计数器 无 虚拟机栈 StackOverflowError 线程请求的栈深度大于虚拟机栈所允许的深度 Ou ...
- 非常好用的正则表达式"\\s+" - 匹配任意空白字符
说起来,博主使用过的正则场景虽然不多,但是就是在这当中,我发现"\\s+"真好用! 详解 "\\s+" 正则表达式中\s匹配任何空白字符,包括空格.制表符.换页 ...
- java怎么连接sql server,需要注意的几点
一.JAVA连接SQL的语句 JAVA连接SQL2000语句为: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Drive ...