zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    Vue让水平滚动条(scroll bar)固定在浏览器的底部,并且同轴联动
    vue横向滚动条,初始化位置
    VUE父子组件传值,以及子组件调用父组件方法
    获取shell脚本所在路径而非执行路径
    免重装完整迁移ubuntu18.04系统方法
    auth.log大量出现pam_unix(cron:session): session opened for user root by (uid=0)解决办法
    禁用vim的visual模式方便拖选
    ssh端口反向代理与内网穿透
    mysql查询时将时间戳转换为时间格式
    浏览器打印控件分享
  • 原文地址:https://www.cnblogs.com/hsd-/p/7401875.html
Copyright © 2011-2022 走看看