Added hit formula to C++