Advertisement
Guest User

Untitled

a guest
Jan 6th, 2016
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #define MAX(a,b) ((a)>(b)?(a):(b))
  2. #define MIN(a,b) ((a)<(b)?(a):(b))
  3. #define filer() freopen("in.txt","r",stdin)
  4. #define filew() freopen("out.txt","w",stdout)
  5. #define SET(a, x) memset((a), (x), sizeof(a))
  6. #define ll long long
  7. #include<iostream>
  8. #include<stdio.h>
  9. #include<string.h>
  10. #include<math.h>
  11. #include<algorithm>
  12. #include<queue>
  13. #include<stack>
  14. #include<vector>
  15.  
  16. using namespace std;
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25. //filer();
  26. double L,n,C,arc,hi,lo,mid,r2,r1,d,a;
  27. int T,cas=0;
  28. scanf("%d",&T);
  29. while(T--)
  30. {
  31. scanf("%lf%lf%lf",&L,&n,&C);
  32. if(L<0 && n<0 &&C<0)break;
  33. arc=(1+(n*C))*L;
  34. //printf("%lf\n",arc);
  35. hi=(acos(-1)/2.00);
  36. //printf("%lf\n",hi);
  37. lo=1e-9;
  38.  
  39. while(fabs(hi-lo)>1e-9)
  40. {
  41. mid=(hi+lo)/2.0;
  42. r1=arc/(2.0*mid);
  43. r2=L/(2*sin(mid));
  44.  
  45.  
  46. //printf("%lf %lf %lf %lf\n",r1,r2,mid,fabs(r1-r2));
  47. if(fabs(r1-r2)<1e-7)
  48. {
  49. a=r2-(r2*cos(mid));
  50. printf("Case %d: %.6lf\n",++cas,a);
  51. break;
  52. }
  53. else if(r1>r2)lo=mid+1e-7;
  54. else hi=mid-1e-7;
  55. }
  56. }
  57.  
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement