Fighting with computers

Computers are not always friendly.

Wednesday, September 16, 2009

Could not make it to the second round

I've failed to make it to round 2 of Code Jam 2009 last weekend.

I failed on getting the first problem (All your bases) right and that ate most of my available time. I was able to get the third one (Bribe the prisoners) right (bruteforcing it, not very elegant).

So I used some time to get the first problem right after the contest :-)

By the way, I later learned that there was a hidden constraint, as output value could not be larger than 10^18. That meant that maximum base could be 16 (as 1023456789abcdefg is base-17 is larger than that, 49030176097150555672 in case you're wondering).

Here you have a simple solution in Java. And, yes, you can use Long.toString(String,int) instead of BigInteger, though the latter will cover a wider range than the problem statement requirements.

0 Comments:

Post a Comment

<< Home