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  k
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 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\n",ans*acos(-1.0));
42     }
43     return 0;
44 }

 

相关文章:

  • 2021-04-11
  • 2021-06-18
猜你喜欢
  • 2022-03-03
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-06-08
  • 2021-04-07
相关资源
相似解决方案