This is the link to the question: http://www.codechef.com/problems/CHMOD My final solution (WA shown) http://www.codechef.com/viewsolution/3447265 I implemented this. However, I kept getting Time limit crossed. So I went through the tutorial. I saw that I had followed more or less whatever they did, just that I didn't use the cumulative prime factorization scheme so we could get the prime factorization of a segment in O(1) time. So I tried implementing what they did. Now the problem occurring is:
Anyways, I'm getting shown as WA. Have I identified the problem correctly? If yes, how to go about it then? If no, could you help me find the problem? Any help would be greatly appreciated. Stuck for quite some time.
This question is marked "community wiki".
asked 20 Feb '14, 19:09

If N=600000, the second array should have around 57 MB, because long int is the same as int. That should fit into any general memlimit (unless you're COCI with stupid 32 MB limits), but it could theoretically overflow stack size. In that case, using vector<>s is better.
declare the array globally...let the array be on heap...if the size is too large...maybe this will help..:)