# 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

Input
The first line contains a integer

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 }