bzoj 2178 自适应Simpson积分
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
const double eps = 1e-;
struct node
{
double x,y,r;
}b[],a[];int cnt;
bool cmp1(node aa,node bb)
{
return aa.r<bb.r;
}
bool v[];
double dis(int x,int y)
{
return sqrt((b[x].x-b[y].x)*(b[x].x-b[y].x)+(b[x].y-b[y].y)*(b[x].y-b[y].y));
}
double lmin,rmax;
pair<double,double>q[];
double mx(double x,double y)
{
return x<y?y:x;
}
double f(double x)
{
int top=;double len=;
for(int i=;i<=cnt;i++)
{
double xx=fabs(a[i].x-x);
if(fabs(xx)<=a[i].r)
{
double ww=sqrt(a[i].r*a[i].r-xx*xx);
q[++top].first=a[i].y-ww;
q[top].second=a[i].y+ww;
}
}
sort(q+,q+top+);len+=q[].second-q[].first;
double rs=q[].second;
for(int i=;i<=top;i++)if(q[i].second>rs)len+=q[i].second-mx(q[i].first,rs),rs=q[i].second;
return len;
}
double asr(double l,double mid,double r,double A,double B,double C)
{
double s=((r-l)/)*(A+*B+C),lf=f((l+mid)/),rf=f((mid+r)/);
double ls=((mid-l)/)*(A+B+*lf),rs=((r-mid)/)*(B+C+*rf);
if(fabs(s-ls-rs)<=eps)return s;
return asr(l,(l+mid)/,mid,A,lf,B)+asr(mid,(r+mid)/,r,B,rf,C);
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lf%lf%lf",&b[i].x,&b[i].y,&b[i].r);
lmin=min(lmin,b[i].x-b[i].r);rmax=max(rmax,b[i].x+b[i].r);
}
sort(b+,b+n+,cmp1);
for(int i=;i<=n;i++)
{
for(int j=;j<i;j++)
{
if(dis(i,j)<=b[i].r-b[j].r)v[j]=;
}
}
for(int i=;i<=n;i++)if(!v[i])a[++cnt]=b[i];
printf("%.3f\n",asr(lmin,(lmin+rmax)/,rmax,,f((lmin+rmax)/),));
return ;
}
bzoj 2178 自适应Simpson积分的更多相关文章
- 自适应Simpson积分
自适应Simpson积分 作用 如标题所示,这玩意就是当你不会微积分的时候来求积分的. 总所周知,积分的定义就是函数的某一段与坐标轴之间的面积. 那么,自适应Simpson积分就是一种可以再某些精度下 ...
- 【bzoj1502】[NOI2005]月下柠檬树 自适应Simpson积分
题目描述 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月 ...
- HDU 1724 Ellipse 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- CSU 1806 Toll 自适应simpson积分+最短路
分析:根据这个题学了一发自适应simpson积分(原来积分还可以这么求),然后就是套模板了 学习自适应simpson积分:http://blog.csdn.net/greatwall1995/arti ...
- 【BZOJ-1502】月下柠檬树 计算几何 + 自适应Simpson积分
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1017 Solved: 562[Submit][Status] ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
- 【BZOJ1502】[NOI2005]月下柠檬树 Simpson积分
[BZOJ1502][NOI2005]月下柠檬树 Description 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树 ...
- [BZOJ1502]月下柠檬树(自适应辛普森积分)
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1387 Solved: 739[Submit][Status] ...
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
随机推荐
- AES128加密算法完整实现
概述 原本想把自己AES加密算法的整个实现过程给详细复述下来,分享给想学习的同学,也方便自己复习,但后来发现该工作量太大,加上作业太多没有过多的时间去写.所以就想把自己在学习的过程中多遇到的好的文章进 ...
- Vim YouCompleteMe 安装配置
YouCompleteMe是很强大的vim插件,可以提供强大的补齐功能,曾经多次尝试安装,都没有配置成功,最近在一个契机下,看到有同事的配置,自己在边尝试和边咨询后,终于也搞定了,遂记录下. 官网有最 ...
- C++ Style Languages: C++, Objective-C, Java, C#
Hyperpolyglot.org From Hyperpolyglot.org C++ Style Languages: C++, Objective-C, Java, C# a side-by-s ...
- 第31次Scrum会议(11/19)【欢迎来怼】
一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,阚博文 小组照片 二.开会信息 时间:2017/11/19 17:05~17:34,总计29min. 地 ...
- BeanUtils解决日期问题
ConvertUtils.register(new DateLocaleConverter(), Date.class); BeanUtils.populate(user, request.getPa ...
- 用java进行简单的万年历编写
import java.util.Scanner; public class PrintCalendarDemo1 { public static void main(String[] args) { ...
- Sprint会议2
昨天:准备查找安卓APP开发的有关资料,安装有关软件 今天:自己制作一个安卓小程序,熟悉一下操作 遇到问题:安装遇到问题,环境配置出现问题
- struts2.3.16.1+hibernate4.3.4+spring4.0.2
把之前的老项目用新的改了 发现新的有点很方便啊 Struts2+Hibernate+Spring整合 用的是 struts2.3.16.1 hibernate4.3.4 ...
- Codeforces Round #106 (Div. 2) D. Coloring Brackets 区间dp
题目链接: http://codeforces.com/problemset/problem/149/D D. Coloring Brackets time limit per test2 secon ...
- ns3 模拟无线网络通信
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This program is fre ...