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.

InputThe 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.

OutputFor 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

笛卡尔定理

若平面上四个半径为r1、r2、r3、r4的圆两两相切于不同点,则其半径满足以下结论:
(1)若四圆两两外切,则

(2)若半径为r1、r2、r3的圆内切于半径为r4的圆中,则

。    -------百度百科

 
韦达定理
 
设一元二次方程

中,两根x₁、x₂有如下关系:

 
-------百度百科
 
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const double eps = 1e-;
const double PI = acos(-1.0); void Debug()
{
puts("");
cout<<"+++++++++++++++++++++++++++分界线++++++++++++++++++++++++++++++"<<endl;
for(int i=; i<; i++)
{
for(int j=; j<; j++)
{
cout<<<<" ";
}
cout<<endl;
}
cout<<"+++++++++++++++++++++++++++分界线++++++++++++++++++++++++++++++"<<endl;
puts("");
} int n;
double r1, r2, r3,r4;
double ans;
void sovel()
{
if(r1 < r2) swap(r1,r2);
r3 = r1-r2;
double k1 = -1.0/r1, k2 = 1.0/r2, k3 = 1.0/r3, k4 = k1+k2+k3;
ans = r3*r3;
for(int i = ; i <= n; i++)
{
r4 = 1.0/k4;
ans += r4*r4;
if(r4*r4 < eps) break;
if(i+ <= n) ans +=r4*r4, i++;
double k5 = *(k1+k2+k4) - k3;
k3 = k4;
k4 = k5;
}
printf("%.5f\n", ans*PI); } int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie();
int T;
cin >> T;
while(T--)
{
cin >> r1 >>r2 >> n;
sovel(); }
return ;
}

圆的反演 :

http://www.cnblogs.com/flipped/p/7397942.html

The Designer (笛卡尔定理+韦达定理 || 圆的反演)的更多相关文章

  1. CF77E Martian Food(圆的反演or 笛卡尔定理+韦达定理)

    题面 传送门 这题有两种方法(然而两种我都想不到) 方法一 前置芝士 笛卡尔定理 我们定义一个圆的曲率为\(k=\pm {1\over r}\),其中\(r\)是圆的半径 若在平面上有两两相切,且六个 ...

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

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

  3. 爆炸几何之 CCPC网络赛 I - The Designer (笛卡尔定理)

    本文版权归BobHuang和博客园共有,不得转载.如想转载,请联系作者,并注明出处.   Nowadays, little hahahaha got a problem from his teache ...

  4. HDU 6158 笛卡尔定理 几何

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

  5. 19牛客暑期多校 round1 A 有关笛卡尔树的结论

    题目传送门//res tp nowcoder 分析 定理:B1~B2当且仅当B1与B2有同构的笛卡尔树. (B₁~B₂ iff B₁ and B₂ have isomorphic Cartesian ...

  6. codevs2178 表达式运算Cuties[笛卡尔树]

    2178 表达式运算Cuties  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Description 给出一个表达 ...

  7. POJ 2559 Largest Rectangle in a Histogram ——笛卡尔树

    [题目分析] 本来是单调栈的题目,用笛卡尔树可以快速的水过去. 把每一个矩阵看成一个二元组(出现的顺序,高度). 然后建造笛卡尔树. 神奇的发现,每一个节点的高度*该子树的大小,就是这一块最大的子矩阵 ...

  8. NOIP2011pj表达式的值[树形DP 笛卡尔树 | 栈 表达式解析]

    题目描述 对于1 位二进制变量定义两种运算: 运算的优先级是: 先计算括号内的,再计算括号外的. “× ”运算优先于“⊕”运算,即计算表达式时,先计算× 运算,再计算⊕运算.例如:计算表达式A⊕B × ...

  9. CROSS JOIN连接用于生成两张表的笛卡尔集

    将两张表的情况全部列举出来 结果表: 列= 原表列数相加 行= 原表行数相乘     CROSS JOIN连接用于生成两张表的笛卡尔集. 在sql中cross join的使用: 1.返回的记录数为两个 ...

随机推荐

  1. Zookeeper系列六:服务器角色、序列化与通信协议、数据存储、zookeeper总结

    一.服务器角色 1. Leader 1)事务请求的唯一调度者和处理者.保证事务处理的顺序性 事务请求:导致数据一致性的请求(数据发生改变).如删除一个节点.创建一个节点.设置节点数据,设置节点权限就是 ...

  2. php7新特性总结

    PHP新功能总结 改进的性能 - 将PHPNG代码合并到PHP7中,速度是PHP 5的两倍. 降低内存消耗 - 优化的PHP 7使用较少的资源. 标量类型声明 - 现在可以强制执行参数和返回类型. 一 ...

  3. C#中 Excel和其他文件类型的Content-Type/mime-type

    C#中 Excel和其他文件类型的Content-Type/mime-type For BIFF .xls files application/vnd.ms-excel For Excel2007 a ...

  4. laravel5.8笔记二:部署

    部署项目之前需要知道的几件事 1.有几个模块(admin,index,wap,api) 2.有几个数据库(mysql1,mysql2,mysql3) 3.有那些缓存(redis1,redis2,red ...

  5. python利用opencv合成模糊图像

    之前需要评估图像质量来筛选成像质量不错的图片,去除由于对焦,运动等造成的模糊图像,所以在构建数据集的时候考虑用opencv对清晰的图片进行处理获得模糊的图片从而进行训练. 1) 运动模糊图像 一般来说 ...

  6. MySQL设置密码复杂度

    MySQL5.6.6版本之后增加了密码强度验证插件validate_password,相关参数设置的较为严格.使用了该插件会检查设置的密码是否符合当前设置的强度规则,若不满足则拒绝设置. 本文采用测试 ...

  7. Spark连接MongoDB之Scala

    MongoDB Connector for Spark Spark Connector Scala Guide spark-shell --jars "mongo-spark-connect ...

  8. GBDT 详解分析 转+整理

    GBDT DT 回归树 Regression Decision Tree 梯度迭代 GBDT工作过程实例 需要解释的三个问题 - 既然图1和图2 最终效果相同,为何还需要GBDT呢? - Gradie ...

  9. poj 3525

    多边形内最大半径圆. 哇没有枉费了我自闭了这么些天,大概五天前我看到这种题可能毫无思路抓耳挠腮举手投降什么的,现在已经能1A了哇. 还是先玩一会计算几何,刷个几百道 嗯这个半平面交+二分就阔以解决.虽 ...

  10. F#周报2019年第3期

    新闻 SAFE最近的活动 什么开源项目适合我们的奖学金受益者上手工作 布署SAFE应用至Google Cloud AppEngine Alea GPU:使用F#进行GPU编程 Rider 2018.3 ...