码迷,mamicode.com
首页 > 其他好文 > 详细

G.Finding the Radius for an Inserted Circle 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

时间:2017-10-04 00:19:05      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:back   clu   oca   make   contain   target   tar   lan   ica   

地址:https://nanti.jisuanke.com/t/17314

题目:

Three circles C_{a}C?a??, C_{b}C?b??, and C_{c}C?c??, all with radius RR and tangent to each other, are located in two-dimensional space as shown in Figure 11. A smaller circle C_{1}C?1?? with radius R_{1}R?1?? (R_{1}<RR?1??<R) is then inserted into the blank area bounded by C_{a}C?a??, C_{b}C?b??, and C_{c}C?c?? so that C_{1}C?1?? is tangent to the three outer circles, C_{a}C?a??, C_{b}C?b??, and C_{c}C?c??. Now, we keep inserting a number of smaller and smaller circles C_{k}\ (2 \leq k \leq N)C?k?? (2kN) with the corresponding radius R_{k}R?k?? into the blank area bounded by C_{a}C?a??, C_{c}C?c?? and C_{k-1}C?k1?? (2 \leq k \leq N)(2kN), so that every time when the insertion occurs, the inserted circle C_{k}C?k?? is always tangent to the three outer circles C_{a}C?a??, C_{c}C?c?? and C_{k-1}C?k1??, as shown in Figure 11

技术分享

Figure 1.

(Left) Inserting a smaller circle C_{1}C?1?? into a blank area bounded by the circle C_{a}C?a??, C_{b}C?b?? and C_{c}C?c??.

(Right) An enlarged view of inserting a smaller and smaller circle C_{k}C?k?? into a blank area bounded by C_{a}C?a??, C_{c}C?c?? and C_{k-1}C?k1?? (2 \leq k \leq N2kN), so that the inserted circle C_{k}C?k?? is always tangent to the three outer circles, C_{a}C?a??, C_{c}C?c??, and C_{k-1}C?k1??.

Now, given the parameters RR and kk, please write a program to calculate the value of R_{k}R?k??, i.e., the radius of the k-thkth inserted circle. Please note that since the value of R_kR?k?? may not be an integer, you only need to report the integer part of R_{k}R?k??. For example, if you find that R_{k}R?k?? = 1259.89981259.8998 for some kk, then the answer you should report is 12591259.

Another example, if R_{k}R?k?? = 39.102939.1029 for some kk, then the answer you should report is 3939.

Assume that the total number of the inserted circles is no more than 1010, i.e., N \leq 10N10. Furthermore, you may assume \pi = 3.14159π=3.14159. The range of each parameter is as below:

1 \leq k \leq N1kN, and 10^{4} \leq R \leq 10^{7}10?4??R10?7??.

Input Format

Contains l + 3l+3 lines.

Line 11: ll ----------------- the number of test cases, ll is an integer.

Line 22: RR ---------------- RR is a an integer followed by a decimal point,then followed by a digit.

Line 33: kk ---------------- test case #11, kk is an integer.

\ldots

Line i+2i+2: kk ----------------- test case # ii.

\ldots

Line l +2l+2: kk ------------ test case #ll.

Line l + 3l+3: -11 ---------- a constant -11 representing the end of the input file.

Output Format

Contains ll lines.

Line 11: kR_{k}R?k?? ----------------output for the value of kk and R_{k}R?k?? at the test case #11, each of which should be separated by a blank.

\ldots

Line ii: kR_{k}R?k?? ----------------output for kk and the value of R_{k}R?k?? at the test case # ii, each of which should be separated by a blank.

Line ll: kR_{k}R?k?? ----------------output for kk and the value ofR_{k}R?k?? at the test case # ll, each of which should be separated by a blank.

样例输入

1
152973.6
1
-1

样例输出

1 23665

题目来源

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

 

思路:

  圆的反演。

  很容易想到把上面两大圆的切点作为反演中心,这样会得到下图。

技术分享

  绿色的是反演前的圆,黄色的是反演后的图形,两个大圆成了平行直线,下面的大圆成了直线间的小圆,后面添加的圆都在这个小圆的下面。

  所以求出小圆的圆心的y即可,然后反演回去可以得到半径。

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 #define MP make_pair
 6 #define PB push_back
 7 typedef long long LL;
 8 typedef pair<int,int> PII;
 9 const double eps=1e-8;
10 const double PI=acos(-1.0);
11 const int K=1e6+7;
12 const int mod=1e9+7;
13 
14 
15 int main(void)
16 {
17     double r,x,y,ls,dis,ans[11];
18     int t;
19     cin>>t>>r;
20     x=0.5*r,ls=-0.5*sqrt(3.0)*r;
21     dis=x*x+ls*ls;
22     ls=ls/dis;
23     r=1.0/(2*r);
24     for(int i=1;i<=10;i++)
25     {
26         y=ls-r*2;
27         ans[i]=0.5*(1.0/(y-r)-1.0/(y+r));
28         ls=y;
29     }
30     for(int i=1,k;i<=t;i++)
31         scanf("%d",&k),printf("%d %d\n",k,(int)ans[k]);
32     return 0;
33 }

 

G.Finding the Radius for an Inserted Circle 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

标签:back   clu   oca   make   contain   target   tar   lan   ica   

原文地址:http://www.cnblogs.com/weeping/p/7624767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!