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 ...
随机推荐
- pandas 索引与列相互转化
1. 准备数据 import pandas as pd from io import StringIO csv_txt = '''"date","player1" ...
- EJB开发第一期---EJB开发配置
一.EJB 3.0简介 1.1 什么是EJB Enterprise JavaBeans是一个用于分布式业务应用的标准服务端组件模型.采用Enterprise JavaBeans架构编写的应用是可伸缩的 ...
- [APIO2015]巴厘岛的雕塑[按位贪心+dp]
题意 给你长度为 \(n\) 的序列,要求分成 \(k\) 段连续非空的区间,求所有区间和的 \(or\) 最小值. 分析 定义 \(f_{i,j}\) 表示前 \(i\) 个点分成 \(j\) 段的 ...
- KNN算法的R语言实现
近邻分类 简言之,就是将未标记的案例归类为与它们最近相似的.带有标记的案例所在的类. 应用领域: 1.计算机视觉:包含字符和面部识别等 2.推荐系统:推荐受众喜欢电影.美食和娱乐等 3.基因工程:识别 ...
- Windows10没有修改hosts文件权限的解决方案(亲测有效)
当遇到有hosts文件不会编辑或者,修改了没办法保存”,以及需要权限等问题如图: 或者这样: 我学了一招,现在教给你: 1.win+R 2.进入hosts的文件所在目录: 3.我们开始如何操作才能不出 ...
- mount命令详解及常见问题汇总
一 .mount命令(用来挂载硬盘或镜像等) 用法:mount [-t vfstype] [-o options] device dir1.-t vfstype 指定文件系统的类型,通常不必指定.mo ...
- python+selenium安装方法
一.准备工具: 下载 python[python 开发环境] http://python.org/getit/ 下载 setuptools [python 的基础包工具] http://pypi.py ...
- NO.3:自学tensorflow之路------MNIST识别,神经网络拓展
引言 最近自学GRU神经网络,感觉真的不简单.为了能够快速跑完程序,给我的渣渣笔记本(GT650M)也安装了一个GPU版的tensorflow.顺便也更新了版本到了tensorflow-gpu 1.7 ...
- 3. Python3 基本数据类型
Python3 基本数据类型 Python 中的变量不需要声明.每个变量在使用前都必须赋值,变量赋值以后该变量才会被创建. 在 Python 中,变量就是变量,它没有类型,我们所说的"类型& ...
- 《Linux内核设计与实现》第五章读书笔记
第五章 系统调用 5.1与内核通信 1. 系统调用 让应用程序受限的访问硬件设备 提供创建新进程并与已有进程通信的机制 提供申请操作系统其他资源能力是用户空间进程和硬件设备之间的中间层 2. 系统调 ...