My submission for hdu online judge