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. DZNEmptyDataSet 使用

    gitHub地址:https://github.com/dzenbot/DZNEmptyDataSet 效果图: 代码: #import "UIScrollView+EmptyDataSet ...

  2. java 多线程 day17 Exchanger

    import java.util.concurrent.Exchanger;import java.util.concurrent.ExecutorService;import java.util.c ...

  3. 在线学习--online learning

    在线学习 online learning Online learning并不是一种模型,而是模型的训练方法.能够根据线上反馈数据,实时快速的进行模型调优,使得模型能够及时反映线上的变化,提高线上预测的 ...

  4. c/c++ json使用

    比如出名的有CJson,c++一般用jsoncpp http://sourceforge.net/projects/jsoncpp/ jsoncpp:http://www.cnblogs.com/fe ...

  5. Java多态 父类引用指向子类对象

    Java多态的三个必要条件: 1. 继承 2. 子类重写父类方法 3. 父类引用指向子类对象 然后看一个例子 输出结果为: 给出结论:Father  c  =  new  Child()    在c的 ...

  6. 4.10 Routing -- Asynchronous Routing

    本节介绍了路由器的一些更高级的功能和处理复杂异步逻辑的能力. 一.A word on promises 1. 在Ember的Router中Ember使用了大量的Promises概念来处理异步逻辑.简而 ...

  7. HDU——2955 Robberies (0-1背包)

    题意:有N个银行,每抢一个银行,可以获得\(v_i\)的前,但是会有\(p_i\)的概率被抓.现在要把被抓概率控制在\(P\)之下,求最多能抢到多少钱. 分析:0-1背包的变形,把重量变成了概率,因为 ...

  8. Java backup

    待补充 ........ 0:常用头文件(待补充) import java.util.Arrays; import java.util.HashSet; import java.util.TreeSe ...

  9. CyclicBarrier实现流水处理服务类

    package com.yzu.zhang.thread.concurrent; import java.util.Map.Entry; import java.util.Random; import ...

  10. TED #03# 10 ways to have a better conversation

    Teach you how to talk and how to listen Many of you have already heard a lot of advice on this, thin ...