The Designer

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1115    Accepted Submission(s): 217

Problem Description
Nowadays, little haha got a problem from his teacher.His teacher wants to design a big logo for the campus with some circles tangent with each other. And now, here comes the problem. The teacher want to draw the logo on a big plane. You could see the example of the graph in the Figure1

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.

 
Input
The first line contains a integer t(1≤t≤1200), which means the number of the test cases. For each test case, the first line insist of two integers R1 and R2 separated by a space (1≤R≤100), which are the radius of the two big circles. You could assume that the two circles are internally tangented. The second line have a simple integer N (1≤N≤10 000 000), which is the number of small circles the teacher want to add.
 
Output
For each test case: 
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).
 
Sample Input
2
5 4
1
4 5
1
 
Sample Output
3.14159
3.14159
 
Source
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6160 6159 6158 6157 6156 
 
题目大意:求那些相切的n个圆的面积
题解:利用反演,一和二 ,的性质,具体看本博客反演的归纳
草稿图:
 
如果只是枚举i从1到n是2000+ms,枚举2的步长就降低一半到了1000+ms 
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-;
double pi=acos(-1.0);
double ans,R1,R2,k,rr,r1;
int n,T;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf",&R1,&R2);
scanf("%d",&n);
if (R1>R2) swap(R1,R2);
double k=; //k可以取任意值
double rr=k*k/(*R1)-k*k/(*R2); //反形圆半径
double lx=k*k/(*R2)+rr; //反形圆的圆心到反演点的距离 ans=pi*(R2-R1)*(R2-R1); //因为n>=1
for(int i=;i<=n;i+=)
{
double ly=(i/)**rr;
double l=sqrt(lx*lx+ly*ly); //第i个圆的反形圆的圆心到反演点的距离
double r=( k*k/(l-rr)-k*k/(l+rr) )/2.0; //利用反演求第i个圆的圆心
if (pi*r*r<eps) break;
if (i+>n) ans+=pi*r*r;
else ans+=pi*r*r*;
}
printf("%.5lf\n",ans);
}
}

hdu 6158 The Designer( 反演圆)的更多相关文章

  1. HDU - 6158 The Designer

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6158 本题是一个计算几何题——四圆相切. 平面上的一对内切圆,半径分别为R和r.现在这一对内切圆之间,按 ...

  2. HDU 6158 笛卡尔定理+韦达定理

    The Designer Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  3. HDU 6158 笛卡尔定理 几何

    LINK 题意:一个大圆中内切两个圆,三个圆两两相切,再不断往上加新的相切圆,问加上的圆的面积和.具体切法看图 思路:笛卡尔定理: 若平面上四个半径为r1.r2.r3.r4的圆两两相切于不同点,则其半 ...

  4. 「HDU6158」 The Designer(圆的反演)

    题目链接多校8-1009 HDU - 6158 The Designer 题意 T(<=1200)组,如图在半径R1.R2相内切的圆的差集位置依次绘制1,2,3,到n号圆,求面积之和(n< ...

  5. hdu6158 The Designer

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6158 题目: The Designer Time Limit: 8000/4000 MS (J ...

  6. hdu 1010 深搜+剪枝

    深度搜索 剪枝 还不是很理解 贴上众神代码 //http://blog.csdn.net/vsooda/article/details/7884772#include<iostream> ...

  7. hdu 1284完全背包

    http://acm.hdu.edu.cn/showproblem.php?pid=1284 New~ 欢迎“热爱编程”的高考少年——报考杭州电子科技大学计算机学院关于2015年杭电ACM暑期集训队的 ...

  8. hdu 1548 楼梯 bfs或最短路 dijkstra

    http://acm.hdu.edu.cn/showproblem.php?pid=1548 Online Judge Online Exercise Online Teaching Online C ...

  9. hdu多校1002 Balanced Sequence

    Balanced Sequence Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s) ...

随机推荐

  1. 二.re库介绍

    一.re库的主要功能函数 1.re.search()用法 2.re.match()的用法 >>> match=re.match(r'[1-9]\d{5}','BIT 100081') ...

  2. CSLA.Net学习(2)

    采用CSLA.net 2.1.4.0版本的书写方式: using System; using System.ComponentModel; using Csla.Validation; using S ...

  3. Redis持久化磁盘IO方式及其带来的问题

    有Redis线上运维经验的人会发现Redis在物理内存使用比较多,但还没有超过实际物理内存总容量时就会发生不稳定甚至崩溃的问题 一.对Redis持久化的探讨与理解 redis是一个支持持久化的内存数据 ...

  4. [golang note] 网络编程 - RPC编程

    net包 • 官方文档 http://godoc.golangtc.com/pkg/net/ Package net provides a portable interface for network ...

  5. Java基础知识Set、List、Map的区别

    就学习经验,浅谈Java中的Set,List,Map的区别,对JAVA的集合的理解是相对于数组: 数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型),JAVA集合可以存储和操 ...

  6. Django RF:学习笔记(8)——快速开始

    Django RF:学习笔记(8)——快速开始 安装配置 1.使用Pip安装Django REST Framework: pip install djangorestframework 2.在Sett ...

  7. EditPlus 4.3.2487 中文版已经发布(11月12日更新)

    新的版本修复了粘贴多重选择文本的问题,以及增加了横向扩展列选模式选择范围的快捷键(Ctrl+Alt+→/←).

  8. 20154312曾林 - Exp1 PC平台逆向破解

    1.逆向及Bof基础实践说明 1.1-实践目标 对象:pwn1(linux可执行文件) 目标:使程序执行另一个代码片段:getshell 内容: 手工修改可执行文件,改变程序执行流程,直接跳转到get ...

  9. Python:执行精确的浮点数运算

    需要对浮点数执行精确的计算操作,并且不希望有任何小误差的出现. 浮点数的一个普遍问题是它们并不能精确的表示十进制数.并且,即使是最简单的数学运算也会产生小的误差,比如: >>> a ...

  10. ipod不识别命令

    root@mx6q:~# history 0 sync 1 reboot 2 cd /usr/app/ 3 ls 4 cd extend-sysfs/ 5 ls 6 cd etc/ 7 ls 8 cd ...