Although I wasn’t able to code correctly this question http://www.codechef.com/COOK45/problems/TCP,

but was my following approach correct for solving:

The distance required as the output is basically the integral of the V(t) equation given under the limits (T,0). For computing this, we need to have the value of A,B,C,D. We have four values satisfying the V(t) equation and 4 solutions and three variables are enough for computing the coefficients.

For finding A,B,C,D I used matrix multiplication. For first three values i framed a 3X3 matrix A and B as the corresponding values of v(t). Then a,b,c can be found as matrix X,

```
X=A^(-1)B
```

i.e. X= (Ainverse)*B.

PS: I didn’t use 4*4 matrix to avoid long calculations for finding the inverse. Using values of a,b,c we can find d and thus the distance.