Hehe, when I was studying Mechanics, I actually solved that first part for fun.
(Don't look at me all strangely like that)
Anyway, the variable you need to deal with here is θ, the angle of projection.
Vertically, the initial velocity is u sin θ, the final velocity will be -u sin θ (due to conservation of energy) and the acceleration is -g. We can work out how much time it will take to hit the floor by using the kinematic equation: a = (v-u)/t
Rearrange to get t: t = (v-u)/a = 2u sin θ/g.
Horizontally, the initial velocity is u cos θ, the acceleration is 0 (because the only force acting on it is gravity, vertically downwards) and as we've just worked out, the time is 2u sin θ/g.
We can use another equation, s = ut + at:2/2, to work out how far the projectile will travel. As a is 0, this simplifies to ut, which is 2u sinθ/g * u cosθ. 2u²/g is constant, which just leaves us with sinθ*cosθ to maximise.
sinθcosθ is maximal when its derivative is 0. We can use the product rule of differentiation to show that the derivative is cos²θ - sin²θ.
Trigonometric identities say that cos²θ + sin²θ = 1, so we can say that the derivative is also 2cos²θ - 1. The distance is maximal when this is 0, so we need to solve 2cos²θ = 1.
cos²θ = 1/2
cosθ = 1/√2.
θ = cos-¹ (1/√2) = 45°.
(That was kind of obvious anyway, but we need to do it properly )
So now we know that the maximal value of θ is 45°, we can substitute it in.
cos 45° * sin 45° = 1/2, so (2u²/g * cosθsinθ)max = u²/g.
The maximum height reached can be worked out by resolving vertically again.
The initial velocity is u cos 45°, the acceleration is -g and the maximum height will be when the projectile's velocity is 0.
Using another kinematic equation, v² = u² + 2as, and rearranging, gets:
s = (v² - u²)/2a
Substituting our values of v, u and a gives s = (u cos 45°)² / 2g = u² / 4g.
In the final part, the angle must be changed so that the projectile just skims the ceiling. The angle wants to be as high as it can, but the ceiling restricts it.
So, resolving vertically once again, the distance is H/2 which is u² / 8g, the initial velocity is u sinθ, the final velocity is 0 and the acceleration is -g.
Rerranging the same equation as before to find the initial velocity gives:
u = √(v² - 2as)
In terms of our problem, this means that u sinθ = √(u²/8) = u/√8.
So, sinθ = 1/√8 and so θ = 20.7°, to 1 decimal place.
Now that we know the angle, we can work out how long it will stay in the air.
As before, the time is found by 2u sinθ /g, which is u√2/g.
So now we have everything we need to work out the range.
As before, s = velocity * time, which is u cos 20.7° * u√2/g.
This works out to be 0.661u²/g, to 3 significant figures.
Sorry for taking so long, in terms of both time and writing, but I haven't done this for half a year so I'm a bit rusty. If you don't understand any of it, feel free to ask again.