Home > Back-end >  Turn to post!
Turn to post!

Time:09-16

Blue cup k times the title of the space, here is my code: (score is 28, is what went wrong?
#include
#include
Int main ()
{
Int N, k, a [100001], I, s [100001], Max=100000, flag [100001]={0};
The scanf (" % d % d ", & amp; N, & amp; K);
Int sum=0, count=0;
for(i=0; i{
The scanf (" % d ", & amp; A [I]);
The sum +=a [I];
S [I]=sum % k;
Flag [s] [I] + +;
If (max}
for(i=0; i<=Max; I++)
{
If (I==0) count +=flag flag [I] + [I] * (flag [I] 1)/2;
The else count +=flag [I] * (flag [I] 1)/2;
}
Printf (" % d ", count);
return 0;
}


This has been test is not passed, I want to know what the reason is,

CodePudding user response:

 a [100001], I, s [100001], Max=100000, flag [100001]={0}; 

I don't have enough space on the stack, the building Lord this suddenly defines four arrays, each array and so big, suggested that the original poster with dynamic application space malloc/free,

CodePudding user response:

What is the original?
Look at your code, flag multiplication (a spell and factorial), estimated result is beyond the scope int

CodePudding user response:

The title?
In order to answer your question
Don't have to go to play?
  • Related