标签:point ever ane log hand blog sum add its
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6158
题目:
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1381 Accepted Submission(s): 289
思路:
圆的反演。
把俩个大圆的切点当做反演中心,可以得到下图:
这样每个圆都变成同大小的圆了,那怎么计算半径呢?
这样一次算下去,直到后面的圆不影响答案时结束。
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 #define MP make_pair 6 #define PB push_back 7 typedef long long LL; 8 typedef pair<int,int> PII; 9 const double eps=1e-8; 10 const double PI=acos(-1.0); 11 const int K=1e6+7; 12 const int mod=1e9+7; 13 14 int main(void) 15 { 16 int t,n;cin>>t; 17 while(t--) 18 { 19 double lx,rx,x,y,d,r,nr,s,ans=0; 20 scanf("%lf%lf%d",&lx,&rx,&n); 21 lx=0.5/lx,rx=0.5/rx; 22 if(lx>rx) swap(lx,rx); 23 x=(lx+rx)/2.0; 24 r=(rx-lx)/2.0; 25 for(int i=1;i<=n;i++) 26 { 27 y=(i/2)*r*2; 28 d=sqrt(x*x+y*y); 29 nr=0.5*(1.0/(d-r)-1.0/(d+r)); 30 s=nr*nr*PI; 31 if(s<1e-12) break; 32 ans+=s; 33 } 34 printf("%.5f\n",ans); 35 } 36 37 return 0; 38 }
标签:point ever ane log hand blog sum add its
原文地址:http://www.cnblogs.com/weeping/p/7624487.html