Melnikov theory to all orders and Puiseux series for subharmonic solutions