2nd Accepted Solution to Uva Problem 256 it uses No Precomputation