Advertisement
erfanul007

Light OJ 1056

Jan 7th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vii;
  10. typedef set<int> st;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define read() freopen("input.txt", "r", stdin)
  20. #define write() freopen("output.txt", "w", stdout)
  21. #define cspf(i) printf("Case %d: ", i)
  22. /// Constants
  23. #define eps 1e-9
  24. #define PI acos(-1.0) // 3.1415926535897932
  25.  
  26. int main()
  27. {
  28. int n,i;
  29. scanf("%d",&n);
  30. loop1(i,n){
  31. double w,l,r,s,angle,hi,lo,mid,length;
  32. scanf("%lf : %lf",&l,&w);
  33. cspf(i);
  34. r=(sqrt(w*w+l*l))/2.0;
  35. angle=acos((2*r*r-w*w)/2*r*r);
  36. int k=60;
  37. hi=400;
  38. lo=0;
  39. while(k--){
  40. mid=(lo+hi)/2;
  41. r=mid;
  42. s=r*angle;
  43. l=400-(2*angle);
  44. w=sqrt(2*r*r-2*r*r*cos(angle));
  45. length=2*s+2*l;
  46. if(length<400)
  47. hi=mid;
  48. else
  49. lo=mid;
  50. }
  51. printf("%lf %lf\n",l,w);
  52. }
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement