hdu6158 The Designer
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6158
题目:
The Designer
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1381 Accepted Submission(s): 289

At first, haha's teacher gives him two big circles, which are tangent with each other. And, then, he wants to add more small circles in the area where is outside of the small circle, but on the other hand, inside the bigger one (you may understand this easily if you look carefully at the Figure1.
Each small circles are added by the following principles.
* you should add the small circles in the order like Figure1.
* every time you add a small circle, you should make sure that it is tangented with the other circles (2 or 3 circles) like Figure1.
The teacher wants to know the total amount of pigment he would use when he creates his master piece.haha doesn't know how to answer the question, so he comes to you.
Task
The teacher would give you the number of small circles he want to add in the figure. You are supposed to write a program to calculate the total area of all the small circles.
Contains a number in a single line, which shows the total area of the small circles. You should out put your answer with exactly 5 digits after the decimal point (NO SPJ).
5 4
1
4 5
1
3.14159
思路:
圆的反演。
把俩个大圆的切点当做反演中心,可以得到下图:

这样每个圆都变成同大小的圆了,那怎么计算半径呢?

这样一次算下去,直到后面的圆不影响答案时结束。
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double PI=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int main(void)
{
int t,n;cin>>t;
while(t--)
{
double lx,rx,x,y,d,r,nr,s,ans=;
scanf("%lf%lf%d",&lx,&rx,&n);
lx=0.5/lx,rx=0.5/rx;
if(lx>rx) swap(lx,rx);
x=(lx+rx)/2.0;
r=(rx-lx)/2.0;
for(int i=;i<=n;i++)
{
y=(i/)*r*;
d=sqrt(x*x+y*y);
nr=0.5*(1.0/(d-r)-1.0/(d+r));
s=nr*nr*PI;
if(s<1e-) break;
ans+=s;
}
printf("%.5f\n",ans);
} return ;
}
hdu6158 The Designer的更多相关文章
- 「HDU6158」 The Designer(圆的反演)
题目链接多校8-1009 HDU - 6158 The Designer 题意 T(<=1200)组,如图在半径R1.R2相内切的圆的差集位置依次绘制1,2,3,到n号圆,求面积之和(n< ...
- SharePoint 2013 create workflow by SharePoint Designer 2013
这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...
- SharePoint 2013 Designer 入门教程
SharePoint的使用中,SharePoint Designer是非常重要的工具,我们可以通过Designer设计页面.母版页,维护.管理站点,也可以定制列表表单.数据视图,设计工作流等等.下面总 ...
- O365(世纪互联)SharePoint 之使用Designer报错
前言 在SharePoint Online中使用Designer报错,错误为:This Feature has been disabled by your administrator.找了好久发现原因 ...
- Altium Designer 的entry sheet ,offsheet和port作用(转载)
1.图纸结构 图纸包括两种结构关系: 一种是层次式图纸,该连接关系是纵向的,也就是某一层次的图纸只能和相邻的上级或下级有关系: 另一种是扁平式图纸,该连接关系是横向的,任何两张图纸之间都可以建立信号连 ...
- Rehosting the Workflow Designer
官方文档:https://msdn.microsoft.com/en-us/library/dd489451(v=vs.110).aspx The Windows Workflow Designer ...
- SharePoint 2013 Designer系列之自定义列表表单
在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...
- SharePoint 2013 Designer系列之数据视图
在SharePoint使用中,数据展示是一块很重要的部分,很多时候我们会采用webpart的形式,但是有一些情况,我们不必使用开发,仅需使用Designer即可,下面让我简单介绍下数据视图的使用. 1 ...
- SharePoint 2013 工作流之使用Designer配置示例篇
在SharePoint 2013中,支持SharePoint Designer 2013(以下简称SPD)配置简单的工作流,完成我们的业务需要.下面,我们就举一个小例子,实现SPD配置工作流. 1. ...
随机推荐
- 安装DatabaseLibrary
Using pip pip install robotframework-databaselibrary From Source Download source from https://github ...
- php截取中文字符串时乱码问题
<?php function chinesesubstr($str,$start,$len) { //$str指字符串,$start指字符串的起始位置,$len指字符串长度 $strlen=$s ...
- Effective C++ —— 定制new和delete(八)
STL容器所使用的heap内存是由容器所拥有的分配器对象管理,不是被new和delete直接管理.本章并不讨论STL分配器. 条款49 : 了解new-handler的行为 当operator new ...
- C++11新特性之七——final/override控制
重载和重写的区别参见: C++继承中重载.重写.重定义的区别: 在了解C++11中的final/override关键字之前,我们先回顾一下C++关于重载的概念.简单地说,一个类A中声明的虚函数fun在 ...
- JAVA Comparator 接口排序用法
java的比较器有两类,分别是Comparable接口和Comparator接口. 在为对象数组进行排序时,比较器的作用非常明显,首先来讲解Comparable接口. 让需要进行排序的对象实现Comp ...
- 时序数据库技术体系 – InfluxDB 多维查询之倒排索引
本文转自: http://hbasefly.com/2018/02/09/timeseries-database-5/ 在时序数据库概述一文中,笔者提到时序数据库的基础技术栈主要包括高吞吐写入实现.数 ...
- 真 · windows环境下php7.0以上开启curl方法
看这个说明之前,大家肯定百度在网上看到什么: 配置php.ini ,把curl_dll前的分号去掉 在php.ini中,查找extension=php_curl.dll ,找到后把它前面的分号去掉 之 ...
- LeetCode——Move Zeroes
Description: Given an array nums, write a function to move all 0's to the end of it while maintainin ...
- sort排序和uniq统计命令
author:headsen chen date: 2018-08-13 11:08:09 1,sort:排序的功能,默认安装ASCII码来排序,-n 安装数值排,-r 按照倒序来排 [root@b ...
- struts2的action如果返回null会怎样
action return nullresponse里直接写要返回的东西, 返回null,就是说视图不跳转到任何地方,当然就出现空白页面了.如果想出现页面就需要在struts.xml文件里面配置res ...