2004 lge code jam contest 1 : problem 3