Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3.  
  4. #define _USE_MATH_DEFINES
  5. using namespace std;
  6. typedef long double ld;
  7. typedef long long ll;
  8. long double e = 10e-3;
  9. int m = 3;
  10. double g = 9.81;
  11. ld cx2, cx1, cx0, cy2, cy1, cy0, v, o, ro = 1.225, s = 0.36;
  12.  
  13. ld f(ld a) {
  14. ld alfa = a;
  15. ld alfarad = a * M_PI / 180;
  16. ld b = m * g * cos(o) - (((cy0 + cy1 * alfa + cy2 * alfa * alfa) * ro * v * v * s) / 2);
  17. b /= ((((cx0 + cx1 * alfa + cx2 * alfa * alfa) * ro * v * v * s) / 2) + m * g * sin(o));
  18. return tan(alfarad) - b;
  19. }
  20.  
  21. int main() {
  22.  
  23. cin >> cx2 >> cx1 >> cx0;
  24. cin >> cy2 >> cy1 >> cy0;
  25. cin >> v >> o;
  26.  
  27. v /= 3.6;
  28. o *= M_PI / 180;
  29.  
  30. ld x1, x2, x3, y1, y3;
  31. ld b;
  32. x1 = -5;
  33. x3 = 10;
  34. ld pcos;
  35.  
  36. y1 = f(x1);
  37. y3 = f(x3);
  38.  
  39. if (y1 < 0) {
  40. while (x1 + e < x3) {
  41. x2 = (x1 + x3) / 2;
  42. b = f(x2);
  43.  
  44. if (b > 0) {
  45. x3 = x2;
  46. }
  47.  
  48. if (b < 0) {
  49. x1 = x2;
  50. }
  51. }
  52. }
  53.  
  54. if (y1 > 0) {
  55. while (x1 + e < x3) {
  56. x2 = (x1 + x3) / 2;
  57.  
  58. b = f(x2);
  59.  
  60. if (b > 0) {
  61. x1 = x2;
  62. }
  63.  
  64. if (b < 0) {
  65. x3 = x2;
  66. }
  67. }
  68. }
  69. else
  70. {
  71. x2 = x1;
  72. }
  73.  
  74. if (y3 == 0)
  75. {
  76. x2 = x3;
  77. }
  78.  
  79. ld x = x2 * 100;
  80. ld xld = x;
  81. cout << xld / 100.0 << ' ';
  82.  
  83. pcos = ((((cx0 + cx1 * x2 + cx2 * x2 * x2) * ro * v * v * s) / 2) + m * g * sin(o));
  84. x2 *= M_PI / 180;
  85. ld p = pcos / cos(x2);
  86. ld pp = p * 100;
  87. cout << pp / 100.0 << endl;
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement