Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double x, v,o;
  10. double s,s1,s2,a,t1,t2,t,tmin;
  11. double g = 9.81;
  12.  
  13.  
  14. cin >> x >> v >> o;
  15.  
  16. double orad = o*M_PI/180;
  17. a = (-1)*g*tan(orad);
  18.  
  19. if(x == 0)
  20. {
  21. cout << 0;
  22. return 0;
  23. }
  24. if (x>0)
  25. {
  26. if (o>0)
  27. {
  28. if(v == 0)
  29. {
  30. tmin = sqrt(x/a*(-1));
  31. tmin *= 2;
  32. cout << tmin;
  33. return 0;
  34. }
  35. else
  36. {
  37. s1 = (v*v)/(2*(-1)*a);
  38. s = s1+x;
  39. t1 = (2*s1)/v;
  40. t2 = sqrt(s/((-1)*a));
  41. tmin = 2*t2+t1;
  42. }
  43. }
  44. if (o<0)
  45. {
  46. if (v==0)
  47. {
  48. tmin = sqrt(x/a);
  49. tmin *= 2;
  50. cout << tmin;
  51. return 0;
  52. }
  53. else
  54. {
  55. s1 = (v*v)/(2*a);
  56. s = s1+x;
  57. t1 = (2*s1)/v;
  58. t2 = sqrt(s/a);
  59. t = 2*t2+t1;
  60. tmin = t-(2*t1);
  61. }
  62. }
  63. }
  64. if (x<0)
  65. {
  66. if(v == 0)
  67. {
  68. tmin = sqrt(x/a);
  69. tmin *= 2;
  70. cout << tmin;
  71. return 0;
  72. }
  73. if (o>0)
  74. {
  75. if (v==0)
  76. {
  77. tmin = sqrt(x/a);
  78. tmin *= 2;
  79. cout << tmin;
  80. return 0;
  81. }
  82. else
  83. {
  84. s1 = (v*v)/(2*a);
  85. s = s1+x;
  86. t1 = (2*s1)/v;
  87. t2 = sqrt(s/a);
  88. tmin = 2*t2+t1;
  89. }
  90. }
  91. if (o<0)
  92. {
  93. if (v == 0)
  94. {
  95. tmin = sqrt(x/(a*(-1)));
  96. tmin *= 2;
  97. cout << tmin;
  98. return 0;
  99. }
  100. else
  101. {
  102. s1 = (v*v)/(2*(-1)*a);
  103. s = s1+x;
  104. t1 = (2*s1)/v;
  105. t2 = sqrt(s/((-1)*a));
  106. t = 2*t2+t1;
  107. tmin = t-(2*t1);
  108. }
  109. }
  110. }
  111. cout << tmin;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement