I know that if we have a lagrangian such that
$$ L'=L+\frac{d}{dt}(f(q,t))$$ then the equation of motion will be the same for $L$ or $L'$.
But I would like to know if there is a proof of the opposite, ie :
If $L$ and $L'$ describe the same motion, then $$ L'=L+\frac{d}{dt}(f(q,t))$$
I don't know how to prove it?