This is the link to the question:
My final solution (WA shown)
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:
If I declare the cumulative array as:
Then there are no storage problems. However, say if the input was N=100,000 and all inputs were 64, then the cumulative frequencies for 2 would be (6*100,000)=600,000, which would not fit in an int array.
If I declare it as:
long int A[N], then such an array cannot be initialized as it takes too much space.
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.