It is about multithreading. I tried to solve FCTRL2 using this method, and it worked. But my serial program ran faster than the parallel one. Then I found some programs of gkcs which run faster when using multiple processors. I have two doubts.
Is multithreading allowed on all platforms like Topcoder, Codeforces, etc…
If my program was using 1 unit of memory, will using 4 processors make it 4 units?
Also, is there a bug in my code? I can’t understand why the first solution ran slower than the second.
Hi saphira. FCTRL2 doesn’t have too much scope for a parallel algorithm. The most compute intensive operation is finding all factorials, and that step has a pipeline structure. The other problem you have mentioned requires lots of I/O, so multithreading nearly doubled the efficiency compared to the standard program.
I am not sure on it being allowed on all platforms. However, I can’t see how a person can be stopped from using multiple processors, so my guess is : no.
If your threads all require the separate memory with size equal to that of the serial program, then yes: memory usage will shoot up.
I went through your parallel program. Seems alright.