fork(1) download
  1. #include<bits/stdc++.h>
  2. #define EPS 1e-9
  3. using namespace std ;
  4. const double pi = acos(-1.0);
  5. struct point
  6. {
  7. double x, y;
  8. point() { x = y = 0.0; }
  9. point(double _x, double _y) : x(_x), y(_y) {}
  10.  
  11. bool operator < (point other) const
  12. {
  13. if (fabs(x - other.x) > EPS)
  14. return x < other.x;
  15. else
  16. return y < other.y;
  17. }
  18.  
  19. bool operator == (point other) const {
  20. return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS)); }
  21. };
  22.  
  23. double dist(point p1, point p2)
  24. {
  25. return (hypot(p1.x - p2.x, p1.y - p2.y));
  26. }
  27. struct vec { double x, y;
  28. vec(double _x, double _y) : x(_x), y(_y) {} };
  29.  
  30. vec toVec(point a, point b) {
  31. return vec(b.x - a.x, b.y - a.y); }
  32.  
  33. vec scale(vec v, double s) {
  34. return vec(v.x * s, v.y * s); }
  35.  
  36. point rotate_point(float cx,float cy,float angle,point p)
  37. {
  38. float s = sin(angle);
  39. float c = cos(angle);
  40. p.x -= cx;
  41. p.y -= cy;
  42.  
  43. float xnew = p.x * c - p.y * s;
  44. float ynew = p.x * s + p.y * c;
  45.  
  46. p.x = xnew + cx;
  47. p.y = ynew + cy;
  48. return p;
  49. }
  50.  
  51. int main()
  52. {
  53. std::cout << std::setprecision(6) << std::fixed;
  54. int T;
  55. cin >> T ;
  56. while(T--)
  57. {
  58. double x,y,r ;
  59. cin >> x >> y >> r ;
  60. point C(x,y) ;
  61. point O ;
  62. double ang1 = asin(r/dist(O,C)) ;
  63. point rot_pt = rotate_point(0,0,ang1,C) ;
  64. cout<< rot_pt.x*cos(ang1)<<" "<<rot_pt.y*cos(ang1)<<"\n" ;
  65. }
  66. return 0 ;
  67. }
  68.  
Success #stdin #stdout 0s 16064KB
stdin
1
179 56 56
stdout
147.084593 102.015289