Prooving Elastic Collisions equations

Homework Statement

hi everyone ,, how are you all ? ,, i have these two equations and i don't know how to get them :
v1f=((m1-m2)/(m1+m2))*v1i +(2m2/(m1+m2))*v2i
V2f=((2m1/m1+m2))*v1i+((m2-m1)/(m1+m2))*v2i

Homework Equations

m1v1i+m2v2i=m1v1f+m2v2f (conservation of momentum)
0.5m1v1^2i+0.5m2v2i^2=0.5m1v1f^2+0.5m2v2f^2 (conservation of Kinetic Energy)

The Attempt at a Solution

the book reach to taking m1 & m2 as common factor then says divide the kinetic by the momentum then I'll get the results above, but when i divide i get :
v2f=v1i+v1f ,, so someone help me to get the results above because i don't like memorizing and i know that I'll forget in the exam -_-