Hi Lauren,
What may not be clear at first is that the cannon is on top of the cliff and the cannonball just barely clears the cliff edge and than travels farther and lands 40m lower.
We can use the range equation for projectile motion to figure out the velocity with which the cannonball leaves the cannon:
vo2sin(2θ)/g = 313m (plug in the given value of θ and the numerical value for g).
After you solve that for vo you can use the vertical component to determine maximum height (above it's starting height) from the kinematics equation:
vf2 - vi2 = -2gh (here vi = vosinθ and vf = 0 because vertical velocity = 0 at the highest point; solve this equation for h)
when the cannonball reaches the cliff edge, by symmetry of it's trajectory it's vertical velocity will be -vosinθ and
its horizontal velocity will be vocosθ .
Now find t from the kinematical formula
-40m = -vosinθ - (1/2)gt2
Apply the t you get to the horizontal velocity to get the horizontal distance from the base of the cliff.
Alternatively, perhaps more easy to solve, determine total height change from maximum height which will be the h you found previously plus 40m. It's a little easier to find the t for that change of height because the initial vertical velocity is 0, so easier quadratic to solve:
-(40 + h) = -(1/2)gt2
Now apply that t to the horizontal velocity to get the total horizontal distance from the x coordinate when height is a maximum. But that distance will include half the distance on top of the cliff (313/2 m), so subtract that amount to get the distance from base of cliff.