Home > Back-end >  [SDOI2014] counting errors
[SDOI2014] counting errors

Time:10-11

Input: 20
3
2
3
14
Desired output: 14
The actual output: 1
Error: your program segment error, may be an array, stack overflow (for example, layer number of recursive calls too much), and so on and so forth cause
 
#include
#include
#include
int n;
int m;
Char s [200] [100000].
Char N [200] [100000].
The main () {
The scanf (" % d ", & amp; n);
The scanf (" % d ", & amp; m);
int i;
for(i=0; iThe scanf (" % s ", s [I]);
}
int j;
For (j=1; j<=n; J++) {
Sprintf (N [1], "% d", j);
}
Int result=0;
Int lucky;
Int p, q;//traverse s and N [j] [I]
for(j=0; jInt ln=strlen (N [j]);
Lucky=0;
for(i=0; iInt the ls=strlen (s [I]);
For (p=0; p<=ln - ls; P++) {
Int flag=1;
While (qIf (s [I] [q]! P + q=N [j] []) {
Flag=0;
break;
}
}
If (flag) lucky++;
}
}
If (lucky=0) result++;
}
Printf (" % d ", result);
}

CodePudding user response:

Char s [200] [100000].
Char N [200] [100000].
This is too big, also use malloc/free,, allocated on the heap was no problem,
  • Related