Блог пользователя wfe2017

Автор wfe2017, история, 8 лет назад, По-английски

I was looking at my previous codes and I noticed a very strange Memory Limit Exceeded Error. The error occurred on test case 24, which has 127 numbers in the array, while in all previous test cases, I used at most 4MB. Does anyone have an explanation? The only large chunk of memory I allotted in my code is a 200,000-longlongint array which shouldn't take more than 2MB. However, in this test case, I used 256MB and got MLE.

http://codeforces.com/contest/615/submission/19726073

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by wfe2017 (previous revision, new revision, compare).

»
8 лет назад, # |
Rev. 3   Проголосовать: нравится +8 Проголосовать: не нравится

While calculating numberoffactor, you haven't considered modulo 1e9 + 7 operation.
So as it overflows the size of long long, it will become negative and your ipow function will keep on calling itself forever, hence the memory limit error because of stack size overflow. I added a line in your ipow function to avoid such case and its not giving memory limit exceeded. Obviously its nor giving AC, but WA.