| ||You may remember an old computer game called "The Incredible Machine". It was a game where you could simulate simple processes like balls falling, lasers shooting, or cats pursuing mice. Moreover, you were able to perform these observations with different values for gravitational acceleration.|
We are observing a system with some unknown acceleration of gravity. There is a slope which has the form of a polyline with N vertices. Each vertex of the polyline is positioned lower and to the right of the previous one. At time 0, a ball is placed at the first vertex. The ball is small enough to be considered a single point. Assume that there's no friction between the slope and the ball, the ball is absolutely nonelastic, and the direction of its velocity changes instantly at the polyline's vertices. Under these conditions, the ball will follow the polyline without ever losing contact with it. The ball reaches the final vertex at time T.
You are given ints x and y, where (x[i], y[i]) are the coordinates of the i-th vertex. Return the gravitational acceleration in this system. A body rolling down an inclined plane of angle alpha (measured between the plane and horizontal direction) under gravitational acceleration g has a constant acceleration of a = g * sin(alpha). The distance d travelled by an object during time t moving with initial velocity v0 and with constant acceleration a is equal to d = v0 * t + 0.5 * a * t^2. The velocity v1 of the object after time t has passed is equal to v1 = v0 + a * t.
|Parameters:||int, int, int|
|Method signature:||double gravitationalAcceleration(int x, int y, int T)|
|(be sure your method is public)|
|-||The returned value must have an absolute or relative error less than 1e-9.|
|-||x will contain between 2 and 50 elements, inclusive.|
|-||Elements of x will be strictly ascending.|
|-||Elements of x will be between 0 and 100, inclusive.|
|-||x and y will contain the same number of elements.|
|-||Elements of y will be strictly descending.|
|-||Elements of y will be between 0 and 100, inclusive.|
|-||T will be between 1 and 100, inclusive.|
|That's an acceleration of gravity that might be somewhere on Earth's surface.
|And this is likely on Jupiter.
|Note that in spite of the angle at vertex (7,6), the body won't fly off the slope and will follow the segment (7,6)-(8,0).