hdu6158 The Designer
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6158
题目:
The Designer
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1381 Accepted Submission(s): 289
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 <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double PI=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int main(void)
{
int t,n;cin>>t;
while(t--)
{
double lx,rx,x,y,d,r,nr,s,ans=;
scanf("%lf%lf%d",&lx,&rx,&n);
lx=0.5/lx,rx=0.5/rx;
if(lx>rx) swap(lx,rx);
x=(lx+rx)/2.0;
r=(rx-lx)/2.0;
for(int i=;i<=n;i++)
{
y=(i/)*r*;
d=sqrt(x*x+y*y);
nr=0.5*(1.0/(d-r)-1.0/(d+r));
s=nr*nr*PI;
if(s<1e-) break;
ans+=s;
}
printf("%.5f\n",ans);
} return ;
}
hdu6158 The Designer的更多相关文章
- 「HDU6158」 The Designer(圆的反演)
题目链接多校8-1009 HDU - 6158 The Designer 题意 T(<=1200)组,如图在半径R1.R2相内切的圆的差集位置依次绘制1,2,3,到n号圆,求面积之和(n< ...
- SharePoint 2013 create workflow by SharePoint Designer 2013
这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...
- SharePoint 2013 Designer 入门教程
SharePoint的使用中,SharePoint Designer是非常重要的工具,我们可以通过Designer设计页面.母版页,维护.管理站点,也可以定制列表表单.数据视图,设计工作流等等.下面总 ...
- O365(世纪互联)SharePoint 之使用Designer报错
前言 在SharePoint Online中使用Designer报错,错误为:This Feature has been disabled by your administrator.找了好久发现原因 ...
- Altium Designer 的entry sheet ,offsheet和port作用(转载)
1.图纸结构 图纸包括两种结构关系: 一种是层次式图纸,该连接关系是纵向的,也就是某一层次的图纸只能和相邻的上级或下级有关系: 另一种是扁平式图纸,该连接关系是横向的,任何两张图纸之间都可以建立信号连 ...
- Rehosting the Workflow Designer
官方文档:https://msdn.microsoft.com/en-us/library/dd489451(v=vs.110).aspx The Windows Workflow Designer ...
- SharePoint 2013 Designer系列之自定义列表表单
在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...
- SharePoint 2013 Designer系列之数据视图
在SharePoint使用中,数据展示是一块很重要的部分,很多时候我们会采用webpart的形式,但是有一些情况,我们不必使用开发,仅需使用Designer即可,下面让我简单介绍下数据视图的使用. 1 ...
- SharePoint 2013 工作流之使用Designer配置示例篇
在SharePoint 2013中,支持SharePoint Designer 2013(以下简称SPD)配置简单的工作流,完成我们的业务需要.下面,我们就举一个小例子,实现SPD配置工作流. 1. ...
随机推荐
- JavaScript jQuery 笔记
资料来源:http://www.w3school.com.cn/jquery/index.asp http://files.cnblogs.com/files/defineconst/jQuery.r ...
- BNU4206:单向行走
给定一个m*n的矩阵,请写一个程序计算一条从左到右走过矩阵且权和最小的路径.一条路径可以从第1列的任意位置出发,到达第n列的任意位置.每一步只能从第i列走到第i+1列的同一行或者相邻行(第一行和最后一 ...
- delphi中Case语法的使用方法
Case 语句If...Then…Else 语句适合选项较少的情况,如果有很多选项的话利用If 语句就比较麻烦,在这种情况下,Case 语句就容易多了.Case 语句的语法如下: case <表 ...
- 手机QQ会员H5加速方案——sonic技术内幕
版权声明:本文由况鹰原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/141 来源:腾云阁 https://www.qclou ...
- IE8及以下的数组处理与其它浏览器的不同
在解决search-box的bug时,由于IE8-的数组处理与其它浏览器的不同,而导致报错. 示例:arr=[1,3,3,]; 当数组的最后是一个逗号时: IE9+默认 arr=[1,3,3];也就是 ...
- Android 获取系统默认输入法
import android.provider.Settings; import android.text.TextUtils; 获取默认输入法包名: private String getDefaul ...
- kerberos认证协议分析
Kerberos认证协议分析 Kerberos认证协议流程 如上图: * 第一步:client和认证服务器(AS)通信完成认证过程,如果认证成功AS返回给client一个TGT(用来向TGS获取tic ...
- 【Mac】Docker安装及基础使用
Docker 安装 在 Mac OS X 系统中,首先你要下载安装包安装:Docker Toolbox 安装过程中,可以选择是否安装 Docker Machine,Docker Compose 等,默 ...
- eclipse 改变颜色,背景
Eclipse背景颜色修改: 操作界面默认颜色为白色.对于我们长期使用电脑编程的人来说,白色很刺激我们的眼睛,所以我经常会改变workspace的背景色,使眼睛舒服一些.设置方法如下: 1.打开win ...
- postgresql----INSERT
INSERT即向表中写入数据,每条INSERT语句可以写入一条数据,也可以写入多条数据.另外还可以将其他的查询结果集用在INSERT中,将查询结果写入表中. 测试表 test)); CREATE TA ...