## Where did Spiderman Reach?

Statement
As we all know, Spiderman is a fast guy. He travels way faster due to his web shooters sticking around those tall skyscrapers and penthouses of The New York City. But, now he needs to compete with The Flash, another fast guy. So, they decide to have a marathon. However, they throw out their superhero suits and race as Peter Parker and Barry Allens. As it is an undisputable that Barry is way faster than Peter, he races with certain change in velocity per unit time ahead ((acceleration more than that of Peter)) of Peter. In the nth second, Barry reaches a certain distance and stops for some reason. And Peter now follows up in same acceleration. You need to find out how much distance does he travel in that "nth" second. Some of the times, the acceleration is backwards too, when the direction of velocity(a vector quantity) is opposite. .////THE MAIN PART\\\\. In short, you need to find the distance reached by Peter in nth second when you are given rate of change in velocity per unit time (Acceleration) or (a). Remember: They may not always start from rest. So their initial velocity may not always be valueless(As, if they start from rest, u=0) Hint: A.P./Arithmetic Sequence Method of Solution can be useful to devise the solution. That is something like [(initial+(GivenChangeRate*(2*nth-1)/2))] AGAIN REMEMBER: REST means that u=0

Input description
•A sentence regarding rate in change of velocity(a) with value at specific index -•Acceleration(a) [a real number]->This is the acceleration at which Barry has travelled •A sentence regarding the initial velocity(u) -•Initial Velocity(u) [a whole number]-> This is the starting velocity at which he starts off. •A sentence regarding the (n) term in time frame -•The nth second(n) [a natural number]->In a series of seconds like 1st second, 2nd seond...; this is one of them

Output description
A sentence with S -•Distance( S )[a whole number ]->The distance reached at nth second

Constraints
• 0<u<999 • -9999<a<9999 • 0=<n<999 • 0<S<999

Game modes

Test cases
Test 1 Test
Input
He travelled in 25 m/s^2 From Rest condition Find distance in 40 term second
Output
Spiderman reached 987 meters.

Validator 1 Validator
Input
Barry travelled in 10 m/s^2 From REsT condition Find distance in 30 term second
Output
Spiderman reached 295 meters.

Test 2 Test
Input
Barry travelled in 100 m/s^2 From 5 m/s Find distance in 700 th second!
Output
Spiderman reached 69955 meters.

Validator 2 Validator
Input
Flash travelled in 659.2 m/s^2 Starting 30 m/s What's distance in 900 part second?
Output
Spiderman reached 592800 meters.

Test 3 Test
Input
Flash travelled in 712.7 m/s^2 Starting 70 m/s What's distance in 20 th second?
Output
Spiderman reached 13954 meters.

Validator 3 Validator
Input
Mr.Allens ran in -12 m/s^2 Starting 500 m/s What's distance in 40 term second?
Output
Spiderman reached 26 meters.

Test 4 Test
Input
Mr.Allens ran in -3 m/s^2 Starting 1999 m/s What's distance in 10 term second?
Output
Spiderman reached 1970 meters.

Validator 4 Validator
Input
Mr.Allens ran in 00 m/s^2 Starting 2004 m/s What's distance in 10 term second?
Output
Spiderman reached 2004 meters.

Test 5 Test
Input
Mr.Allens ran in 00 m/s^2 From 2004 m/s What's distance in 10 term second?
Output
Spiderman reached 2004 meters.

Validator 5 Validator
Input
Mr.Allens ran in -001 m/s^2 Starting 2004 m/s What's distance in 10 term second?
Output
Spiderman reached 1994 meters.

Solution language

Solution

Stub generator input
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants