• 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


    Problem Description
    Nowadays, little haha got a problem from his teacher.His teacher wants to design a big logo for the campus with some circles tangent with each other. And now, here comes the problem. The teacher want to draw the logo on a big plane. You could see the example of the graph in the Figure1



    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.
     
    Input
    The first line contains a integer t(1t1200), which means the number of the test cases. For each test case, the first line insist of two integers R1 and R2 separated by a space (1R100), which are the radius of the two big circles. You could assume that the two circles are internally tangented. The second line have a simple integer N (1N10 000 000), which is the number of small circles the teacher want to add.
     
    Output
    For each test case: 
    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).
     
    Sample Input
    2 5 4 1 4 5 1
     
    Sample Output
    3.14159 3.14159
     
    Source
     
     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<set>
     7 #include<map>
     8 #include<queue>
     9 #include<stack>
    10 #include<vector>
    11 using namespace std;
    12 #define mod 1000000007
    13 typedef long long ll;
    14 int t;
    15 int r1,r2,n;
    16 int main()
    17 {
    18     scanf("%d",&t);
    19     while(t--)
    20     {
    21         scanf("%d %d %d",&r1,&r2,&n);
    22         if(r1<r2) swap(r1,r2);
    23         double k1,k2,k3,k4,ans;
    24         k1=-1.0/r1;
    25         k2=1.0/r2;
    26         k3=1.0/(r1-r2);
    27         k4=k1+k2+k3;
    28         ans=(r1-r2)*(r1-r2);
    29         n--;
    30         for(int i=1; i<=n; i+=2)
    31         {
    32             double r4=1.0/k4;
    33             if(r4*r4<1e-13)
    34                 break;
    35             ans+=r4*r4;
    36             if(i+1<=n) ans+=r4*r4;
    37             double k5=2*(k1+k2+k4)-k3;
    38             k3=k4;
    39             k4=k5;
    40         }
    41         printf("%.5f
    ",ans*acos(-1.0));
    42     }
    43     return 0;
    44 }
  • 相关阅读:
    Spring Boot 的各种start
    Lombok介绍、使用方法和总结
    JS字符串与二进制的相互转化
    java字符串与二进制的相互转化
    DevExpress WPF v18.2新版亮点(六)
    用MyEclipse开发REST Web Service
    .NET界面控件DevExpress发布v18.2.4|附下载
    DevExpress WPF v18.2新版亮点(五)
    「版本升级」MyEclipse CI 2018.12.0正式发布
    MyEclipse使用教程:在Web项目中使用Web片段
  • 原文地址:https://www.cnblogs.com/hsd-/p/7401875.html
Copyright © 2020-2023  润新知