1543. Back to High School Physics

 

Some particle starts moving from rest with constant acceleration. After time t from the start of the motion, the particle’s velocity became v. What distance will the particle travel in time 2t?

 

Input. Each line is a separate test and contains two integers – the particle’s velocity v (0 £ v £ 100) and the time t (0 £ t £ 200), at which the particle reached this velocity.

 

Output. For each test, print the distance the particle will move in time 2t on a separate line.

 

Sample input

Sample output

0 0

5 12

0

120

 

 

SOLUTION

mathematics

 

Algorithm analysis

Let a be the acceleration of the particle. The distance traveled by a uniformly accelerated particle in time t is given by at2 / 2. The velocity of the particle at time t is v = at. In time t1 = 2t, the particle will travel a distance of

s =  =  = 2at2 = 2vt (considering that at = v)

 

Algorithm realization

For each test, read the input values v and t.

 

while(scanf("%d %d", &v,&t) == 2)

 

The distance that the particle will travel by time 2t is equal to s = 2vt.

 

  printf("%d\n",2*v*t);