The speed of the train is: (15+17)/2 =16m/s, just draw a picture.
Then the length of the train is: 15 * (16+1) = 255 m, because A is at the front at first, and15 seconds later is at the rear. Then in 15 seconds, the distance between A and the train is the length of the train.