A solution to POJ 2262