draw a picture |dw:1371797342461:dw| you know the area of the picture + frame is 5000 so $5000 = l \times w$ make w the subject so $w = \frac{l}{5000}$ and you know the area of the pictues is $A_{p} = ( l - 10)(w - 2)$ substitute w $A_{p} = (l - 10)(\frac{l}{5000} - 2)$ you now have an area equation in one unknown find the 1st derivative. set it to 0 and solve for l. this should given the necessary dimensions