Given that,
Distance d=1 km=1000m
Force F=5×105N
∵ Train is moving with constant speed then,
Force applied by the engine = Friction force
Now, the work done by train = work done by friction force
W=F⋅s
W=5×105×1000
W=5×108J
Hence, the work done by the train 5×108J