Advertisement
Korotkodul

ЗОШ геометрия делим отрезок в отношении p / q

Jan 10th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. using namespace std;
  12. using ll = long long;
  13. using ld = long double;
  14. using db = double;
  15. void cv(vector <int> &v){
  16. for (auto x: v) cout<<x<<' ';
  17. cout<<"\n";
  18. }
  19.  
  20. void cvl(vector <ll> &v){
  21. for (auto x: v) cout<<x<<' ';
  22. cout<<"\n";
  23. }
  24.  
  25.  
  26. void cvv(vector <vector <int> > &v){
  27. for (auto x: v) cv(x);
  28. cout<<"\n";
  29. }
  30.  
  31. struct ipn{
  32. int x,y;
  33. };
  34.  
  35. struct rpn{
  36. db x,y;
  37. };
  38.  
  39. rpn div(rpn A, rpn B, db p, db q){
  40. rpn res;
  41. res.x = (q * A.x + p * B.x) / (p + q);
  42. res.y = (q * A.y + p * B.y) / (p+q);
  43. return res;
  44. }
  45.  
  46.  
  47.  
  48.  
  49. int main()
  50. {
  51. ios::sync_with_stdio(0);
  52. cin.tie(0);
  53. cout.tie(0);
  54. cout.precision(20);
  55. rpn a,b,c;
  56. cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
  57. rpn d = div(a, b, 1, 1);
  58. rpn e = div(d, c, 1, 2);
  59. cout<<fixed<<e.x<<' '<<e.y<<"\n";
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement