Bibbidi_Babbidi_Boo's blog

By Bibbidi_Babbidi_Boo, history, 4 years ago, In English

Hi,

I'm new to the CP scene, and I'm trying to get the code working. I'm not able to find the reason for the memory problem. Can someone help me out. Submission 101142835

Thanks

| Write comment?
»
4 years ago, # |
  Vote: I like it +15 Vote: I do not like it

I believe your issue is because of the following code:

while (temp > 1) {
	while (temp%div == 0)
		temp = temp/div;
	a.push_back(div);
	div++;
}

Since temp can be very big, and also not have any divisors, you could end up pushing almost 109 numbers into a. This would happen if temp is a large prime, like 999999937.

Also, just in case you don't know, Div1A and Div2A are of different difficulties. Div1A is equivalent to Div2C, so if you're just starting out, try some Div2A problems first.

»
4 years ago, # |
Rev. 2   Vote: I like it -25 Vote: I do not like it

.