HDOJ1045: REFINE

Make code more compact with while statement instead of for statement.