problem329 finally solved