Calc Word Problem... Need Help!

I have been trying to figure out this problem. I have the answers in the back of the book and saw an attempt of it online, and still am not understanding what was done.

The question says: Supertankers off-load oil at a docking facility 4 miles offshore. The nearest refinery is 9 miles east of the shore point nearest the docking facility. A pipeline must be constructed connecting the docking facility with the refinery. The pipeline costs 300,000 per mile if constructed underwater and 200,000 if over lands.

a) Locate point B to minimize the cost of construction. (Point B forms a triangle with the docking station and point A)

b) The cost of underwater construction is expected to increase whereas the cost of overland construction is expected to stay constant. At what cost does it become optimal to construct the pipeline directly to point A)

If someone could help me with this problem that would be great. Thanks!