Solve SRM 630 DIV2 500

Change-Id: I74642fa8ea75468b1009944b6e10a77cc873fb0c