Advertisement
Sanlover

Untitled

Oct 21st, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double v1, v2, v3, t1, t2, t3, d1, d2, d3, distance, time = 0;
  8. cin >> v1 >> t1 >> v2 >> t2 >> v3 >> t3;
  9.  
  10. d1 = t1 * v1;
  11. d2 = t2 * v2;
  12. d3 = t3 * v3;
  13. distance = (d1 + d2 + d3) / 2;
  14.  
  15. if (d1 > distance)
  16. {
  17. time = (d1 - distance) / v1;
  18. }
  19. else
  20. {
  21. time += t1;
  22. distance -= d1;
  23. if (d2 > distance)
  24. {
  25. time += (d2 - distance) / v2;
  26. }
  27. else
  28. {
  29. time += t2;
  30. distance -= d2;
  31. if (d3 > distance)
  32. {
  33. time += (d3 - distance) / v3;
  34. }
  35. }
  36. }
  37. cout << "Time: " << time;
  38.  
  39. return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement