Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Chef and Segments

$
0
0

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:

  1. If I declare the cumulative array as: int A[N][25] 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.

  2. If I declare it as: long int A[N][25], 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.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>