I am getting a SIGSEGV error in my code for the question: http://www.codechef.com/problems/FCTRL, while it runs perfectly on ideone.com

#include
using namespace std;

long trailing_factorial_zeros(long n) {
int result = 0;
int m5 = 5;
while (n >= m5) {
result += n / m5;
m5 *= 5;
}
return result;
}
 
int main() {
int T=0,i;
long z=0,Z[100];
cin>>T;
cout<<"\n";
for (i=0;i<T;i++) {
	cin>>Z[i];
	z=trailing_factorial_zeros(Z[i]);
	cout<<z<<"\n";
}
return 0;
}

Limit of T is “(equal to about 100000)” in the question. Change the Z[100] to z[100000].

Also note that you don’t need so store the values in any array, since you are not going to use that value further in the program. Just store it in a temporary variable and call the function on it each time.