Part of 2004 South East Mathematical Olympiad
Source: China south east mathematical olympiad 2004 day2 problem 5