圆相切半径4园

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

Figure 1.

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

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

Now, given the parameters RRR and kkk, please write a program to calculate the value of RkR_{k}R?k??, i.e., the radius of the k?thk-thk?th inserted circle. Please note that since the value of RkR_kR?k?? may not be an integer, you only need to report the integer part of RkR_{k}R?k??. For example, if you find that RkR_{k}R?k?? = 1259.89981259.89981259.8998 for some kkk, then the answer you should report is 125912591259.

Another example, if RkR_{k}R?k?? = 39.102939.102939.1029 for some kkk, then the answer you should report is 393939.

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

1≤k≤N1 \leq k \leq N1≤k≤N, and 104≤R≤10710^{4} \leq R \leq 10^{7}10?4??≤R≤10?7??.

Input Format

Contains l+3l + 3l+3 lines.

Line 111: lll ----------------- the number of test cases, lll is an integer.

Line 222: RRR ---------------- RRR is a an integer followed by a decimal point,then followed by a digit.

Line 333: kkk ---------------- test case #111, kkk is an integer.

…\ldots…

Line i+2i+2i+2: kkk ----------------- test case # iii.

…\ldots…

Line l+2l +2l+2: kkk ------------ test case #lll.

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

Output Format

Contains lll lines.

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

…\ldots…

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

Line lll: kkk RkR_{k}R?k?? ----------------output for kkk and the value ofRkR_{k}R?k?? at the test case # lll, each of which should be separated by a blank.

样例输入

1
152973.6
1
-1

样例输出

1 23665

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int T,n;
    double R;
    while(scanf("%d",&T),T!=-1){
        scanf("%lf",&R);
        while(T--){
            scanf("%d",&n);
            double k1=1/R,k2=1/R,k3=1/R;
            double ans;
            for(int i=0;i<n;++i) {
                double B=-2*(k1+k2+k3);
                double C=-(k1+k2+k3)*(k1+k2+k3)+2*(k1*k1+k2*k2+k3*k3);
                double D=B*B-4*C;
                double k4=(-B+sqrt(D))/2;
                ans=1/k4;
                k3=k4;
            }
            printf("%d %d\n",n,floor(ans));
        }
    }
}
				
时间: 2024-12-27 15:23:49

圆相切半径4园的相关文章

java定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积

需求如下:(1)定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积. (2)定义一个类PassObject,在类中定义一个方法printAreas(),该方法的定义如下: public void printAreas(Cirlce c, int times) 在printAreas方法中打印输出1到time之间的每个整数半径值,以及对应的面积.例如,times为5,则输出半径1,2,3,4,5,以及对应的圆面积. 在main方法

1.(1)编写一个接口ShapePara,要求: 接口中的方法: double getArea():获得图形的面积。double getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的dou

package jiekou1; public interface ShapePara { //定义常量PI final double PI=3.14; //定义抽象方法 //获得图形面积 double getArea(); //获得图形周长 double getCircumference(); } package jiekou1; public class Circle implements ShapePara { //定义成员变量 public double radius; public d

Java作业 输入圆的半径计算输出圆的周长和面积

1 package text1; 2 3 import java.util.Scanner; 4 5 public class text11 { 6 public static void main(String[] args){ 7 8 Scanner sc =new Scanner(System.in); 9 10 11 System.out.print("输入圆的半径"); 12 int a =sc.nextInt(); 13 14 15 System.out.print(&quo

(hdu step 7.1.5)Maple trees(求凸包的最小覆盖圆的半径)

题目: Maple trees Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 177 Accepted Submission(s): 63   Problem Description There are a lot of trees in HDU. Kiki want to surround all the trees with the m

创建一个圆类Circle的对象,分别设置圆的半径计算并分别显示圆半径、圆面积、圆周长。

编写一个圆类Circle,该类拥有: ①一个成员变量 Radius(私有,浮点型): // 存放圆的半径: ②两个构造方法 Circle( ) // 将半径设为0 Circle(double r ) //创建Circle对象时将半径初始化为r ③ 三个成员方法 double getArea( ) //计算圆的面积 double getPerimeter( ) //计算圆的周长 void show( ) //将圆的半径.周长.面积输出到屏幕 编写应用程序,创建类的对象,分别设置圆的半径计算并分别显

用C语言实现,输入圆的半径,输出圆的面积和周长

#include <stdio.h> /** 要求:输入圆的半径,输出圆的面积和周长 */ int main(void) { /** 声明一个float类型的变量 radius 来获取半径的值:area来表示面积,perimeter来表示周长 */ float radius; float area; float perimeter; printf("----输入半径以计算圆的面积和周长----\n"); printf("请输入圆的半径:"); scanf

JS函数输出圆的半径和面积

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="

编写一个圆类Circle,该类拥有: ①一个成员变量 Radius(私有,浮点型); // 存放圆的半径; ②两个构造方法 Circle( ) // 将半径设为0 Circle(double r ) //创建Circle对象时将半径初始化为r

package Circle;import java.util.Scanner;public class Circle { private double Radius; public double getRadius() { return Radius; } public void setRadius(double r) { this.Radius=r; } public Circle()//无参构造方法 { this.Radius=0;//初始化为0 System.out.println("圆

(1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量x,

package com.hanqi.test; //创建接口 public interface ShapePara { //获取面积的方法 double getArea(); //获取周长的方法 double getCircumference(); } package com.hanqi.test; public class Circle implements ShapePara { //定义圆心 public double radius; //定义圆心的横向坐标 private double