Sichuan University Programming Contest 2006 Preliminary

H: Math teacher's test