Famous trick question. I'm ashamed your teacher asked it.
All you need to do is ask yourself:
1. How fast are the trains going? Therefore, how long will it be before they collide?
2. How fast is the fly going? How long is it going to be flying before being crushed?
3. Multiply the speed of the fly by the length of time before the trains collide.
Notice there is no need to add up all those vanishing distances to try and find the limit of a sequence of blah, blah, yibbedy yadayada ...