10774 - Repeated Josephus

All about problems in Volume 107. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post by misof »

Well.. are you sure that the code is correct? (I.e. compiler problems only?) I don't have the time to check the whole problem statement and to understand each piece of the posted code, but he declared two maps and used only one of them -- the same map was used in both functions. This may be a bug. After I changed the map used in the second function from m to h, the code worked even with g++-2.95. Wasn't this the source of all the problems?
chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 »

You may be right misof.

I actually tried changing part of the compute function to

int temp = myg(n);
m[n] = temp;
return m[n];

And this worked with g++ 2.95 also. I did notice that he used two maps and h was not used at all. I am also wondering why this happens.
Post Reply

Return to “Volume 107 (10700-10799)”