HDU 6158 笛卡尔定理+韦达定理
The Designer
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 761 Accepted Submission(s): 142

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<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define mod 1000000007
typedef long long ll;
int t;
int r1,r2,n;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d",&r1,&r2,&n);
if(r1<r2) swap(r1,r2);
double k1,k2,k3,k4,ans;
k1=-1.0/r1;
k2=1.0/r2;
k3=1.0/(r1-r2);
k4=k1+k2+k3;
ans=(r1-r2)*(r1-r2);
n--;
for(int i=; i<=n; i+=)
{
double r4=1.0/k4;
if(r4*r4<1e-)
break;
ans+=r4*r4;
if(i+<=n) ans+=r4*r4;
double k5=*(k1+k2+k4)-k3;
k3=k4;
k4=k5;
}
printf("%.5f\n",ans*acos(-1.0));
}
return ;
}
HDU 6158 笛卡尔定理+韦达定理的更多相关文章
- HDU 6158 笛卡尔定理 几何
LINK 题意:一个大圆中内切两个圆,三个圆两两相切,再不断往上加新的相切圆,问加上的圆的面积和.具体切法看图 思路:笛卡尔定理: 若平面上四个半径为r1.r2.r3.r4的圆两两相切于不同点,则其半 ...
- The Designer (笛卡尔定理+韦达定理 || 圆的反演)
Nowadays, little haha got a problem from his teacher.His teacher wants to design a big logo for the ...
- CF77E Martian Food(圆的反演or 笛卡尔定理+韦达定理)
题面 传送门 这题有两种方法(然而两种我都想不到) 方法一 前置芝士 笛卡尔定理 我们定义一个圆的曲率为\(k=\pm {1\over r}\),其中\(r\)是圆的半径 若在平面上有两两相切,且六个 ...
- 爆炸几何之 CCPC网络赛 I - The Designer (笛卡尔定理)
本文版权归BobHuang和博客园共有,不得转载.如想转载,请联系作者,并注明出处. Nowadays, little hahahaha got a problem from his teache ...
- 2018 Multi-University Training Contest 1 H - RMQ Similar Sequence(HDU - 6305 笛卡尔树)
题意: 对于一个序列a,构造一个序列b,使得两个序列,对于任意的区间 [l, r] 的区间最靠近左端点的那个最大值的位置,并且序列 b 满足 0 < bi < 1. 给定一个序列 a ,求 ...
- HDU - 6158 The Designer
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6158 本题是一个计算几何题——四圆相切. 平面上的一对内切圆,半径分别为R和r.现在这一对内切圆之间,按 ...
- HDU - 6305 RMQ Similar Sequence(笛卡尔树)
http://acm.hdu.edu.cn/showproblem.php?pid=6305 题目 对于A,B两个序列,任意的l,r,如果RMQ(A,l,r)=RMQ(B,l,r),B序列里的数为[0 ...
- hdu 6305 RMQ Similar Sequence——概率方面的思路+笛卡尔树
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6305 看题解,得知: 0~1内随机取实数,取到两个相同的数的概率是0,所以认为 b 序列是一个排列. 两个 ...
- hdu 1506 Largest Rectangle in a Histogram——笛卡尔树
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1506 关于笛卡尔树的构建:https://www.cnblogs.com/reverymoon/p/952 ...
随机推荐
- Redis学习之路(四)之Redis集群
[toc] #Redis集群 1.Redis Cluster简介 Redis Cluster为Redis官方提供的一种分布式集群解决方案.它支持在线节点增加和减少. 集群中的节点角色可能是主,也可能是 ...
- 未能正确加载包“Microsoft.Data.Entity.Design.Package.MicrosoftDataEntityDesignPackage(转)
版权声明:作者:jiankunking 出处:http://blog.csdn.net/jiankunking 本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显 ...
- xml中该使用属性还是元素
XML 中没有规定哪些必须放在属性或者子元素,因此使用哪种方式都是可以实现的.这取决于个人的经验和喜好.在可以使用元素也可以使用属性的两选一的情况下,个人更倾向于使用子元素.主要理由如下: 1. 属性 ...
- [arc076F]Exhausted?[霍尔定理+线段树]
题意 地上 \(1\) 到 \(m\) 个位置摆上椅子,有 \(n\) 个人要就座,每个人都有座位癖好:选择 \(\le L\) 或者 \(\ge R\) 的位置.问至少需要在两边添加多少个椅子能让所 ...
- linux下的yum命令详细介绍
yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器自动下载RP ...
- 浅谈android Service和BroadCastReceiver
1.题记 Android中的服务和windows中的服务是类似的东西,服务一般没有用户操作界面,它运行于系统中不容易被用户发觉,可以使用它开发如监控之类的程序. 广播接收者(BroadcastRece ...
- Java关键字 Finally执行与break, continue, return等关键字的关系
长文短总结: 在程序没有在执行到finally之前异常退出的情况下,finally是一定执行的,即在finally之前的return语句将在finally执行之后执行. finally总是在控制转移语 ...
- ANSYS渡槽槽身动水压力的施加(2)——U型渡槽
U型渡槽动水压力荷载施加命令及说明 程序中需要用到ANSYS重启动,因为需提取前一步加速度结果以施加部分动水压力: 默认Y方向为重力方向,X方向为横槽向,Z方向为纵槽向: 需准备地震波文件: 需先将槽 ...
- DRF02
1. 视图 Django REST framwork 提供的视图的主要作用: 控制序列化器的执行(检验.保存.转换数据) 控制数据库查询的执行 1.1. 请求与响应 1.1.1 Request RES ...
- 假设检验,alpha,p值 通俗易懂的的理解。
假设检验: 一般原假设H0 :表是为 XXX和YYYY无显著差异,H1,是有显著差异. 如果我们定义alpha的值是0.05.意味着我们接受H0是真的但是我们却认为他是假的的概率. 这里你想想,这个值 ...