uva 11292 impl in java