Saturday, September 26, 2009
Topcoder | SRM 449 experience
I spent some time on 250 ptr and just didn't understand that if I scale its lower parts to upward, it will become a bigger triangle, and I just have to find the lengths of base and perpendicular of that bigger triangle. The formula was sqrt(2)*(max(finish) - min(start)). This is the solution.
Just no idea clicked and I decided to open 500 ptr because I was pretty sure that it would have been a simpler one. It was simple(only problem statement :) ), as you might have seen but wasn't easy. Again it was a mathematical trick, because brute force solution will surely leads to time out. This was the logic behind it. (The following statements are copied from editorial)
-> If we see, the greatest odd divisor that divides N is N if N is odd or if N is even the greatest odd divisor of N is F(N/2).
-> For (1,N) if N is odd we get 1 + 3 + 5 + ...N + F(2) + F(4)+....F(N-1). The greatest even N is F((N-1)/2).
-> That means the sum F(2) + F(4)+...F(N-1) = F(1) + F(2) + F(3) + F((N-1)/2). Now this is our original problem with N as (N-1)/2.
-> In case of N as even our problem is split into 1+3+5+ ....N-1 and F(2)+ F(4) + ......+ F(N), which is again sum(1,N/2).
-> Now the sum of 1+3+5+.....+N= (N+1)*(N+1)/2
Click here for its solution.
After a sad Coding phase, I decided to gain some points in challenge phase, I was sure that many participants will attempt 500 ptr as brute force so I attacked them, I made 3 challenges one of them was wrong and finished at 75.
Next day, I opened the page to see how much rating points I lost, I was amazed that these were not too many.
Friday, September 4, 2009
Google Code JAM
I saw these stats about google code JAM and I would surely like them to share with all of my readers.
Language statistics
Solutions by Language
Regional Statistics
Hope this will help.
Wednesday, August 26, 2009
Topcoder | SRM 447 experience
Hi all,
Again a very interesting experience.
The most amazing thing was that the count of contestants from
The SRM was special in this sense because it was sponsored by facebook and top 3 positions of a room in DIV I and top 2 positions in DIV II got the prize money.
This time, again, I managed to solve only two problems.
The first problem was a bit simple. See the problem statement:
This simple problem took me 10 minutes to solve and the problem was lack of practice. There were two possible solutions for this problem:
- Sort both arrays in descending order and get the first ever value from “computers” that is greater than or equal to the current value of “complexity”. It can be done in just one loop iteration. See the code.
- Don’t sort the array and just solve it using nested loop. This strategy was a dirty one and I did this :P. See the code
The code for 500 pointer was a bit simple. Just do it as it is given in the problem statement. My code is here, let us see whether some better suggestions are there or not. Looking for comments
Oh! The code is here.
In challenge phase I didn’t participated because I was 3rd after coding phase in my room and there was a chance that after System Tests, I would have been managed to go to 2nd and qualify for the prize money, so same thing happened Al-hamdulillah and I finished at 2nd.