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 ...
随机推荐
- php编译安装扩展curl
./configure --with-php-config=/opt/software/php5.4/bin/php-configyum install curl curl-devel
- 无法绑定到新的显示成员,参数名:newDisplayMember
此问题不是网上说的 DisplayMember 等先后顺序问题,即使更换绑定数序,只是把错误覆盖而已(绑定的是对象的类名) ValueMember = "Id"; DisplayM ...
- spring quartz 多次调用
背景:公司项目有一个定时任务,每月1号0点执行,用到了spring的定时任务.发下定时任务调用的方法执行了俩次.测试部署的客户现场不会有问题 (测试的server.xml不会变化,除非本身提供的tom ...
- php redis 【摘自网上,只为参考】
ubuntu下安装php redis sudo apt-get install redis-server 测试redis是否安装成功:注意:要开启redis redis-cliset test hel ...
- spring源码_下载以及转入eclipse (2016-11-08)
本例spring源码版本是4.3.0的, 所以jdk需要准备1.8的(不同版本源码要求的jdk不一样) 1.8版本myeclipse10无编译环境,只有运行环境,出现点问题,下载最新版本的Eclips ...
- ubuntu 14.04安装amd omega 驱动
驱动共分4部分: fglrx_14.501-0ubuntu1_amd64_UB_14.01.deb 52.0MB fglrx-core_14.501-0ubuntu1_amd64_UB_14 ...
- clientX/Y,pageX/Y,offsetX/Y,layerX/Y,screenX/Y ,offsetTop,offsetLeft 详解
clientX/Y: clientX/Y获取到的是触发点相对浏览器可视区域左上角距离,不随页面滚动而改变 兼容性:所有浏览器均支持 pageX/Y: pageX/Y获取到的是触发点相对文档区域左上角距 ...
- 上传图片预览 支持IE8+,FF,Chrome ,保留原图片比例
代码及效果:链接
- css重置样式表reset.css
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote,/* structural elements 结构元素 */ dl, dt, dd, ul, ol, l ...
- List<Map<String, Object>>相关
2016年8月6日13:53:00 --------------------------- List<Map<String, Object>> List集合新增列 则需要: L ...