Why wrong answer FCTRL ???

,

Gives correct answer to all the inputs in sample, but shows wrong answer during submission.

#include<stdio.h>
#define SIZE 40000
int main(){
	unsigned long T,i,j,ans,cnt,num;
	char Array[SIZE];
	scanf("%lu",&T);
	ans=0;
	num=0;
	while((cnt=fread(Array,1,SIZE,stdin)) > 0){
		for(i=0;i<cnt;i++){
			if(Array[i] == '\n'){
				j=5;
				while(j<=num){
					ans=ans + num/j;
					j=j*5;
				}
				printf("%lu\n", ans);
				ans=0;
				num=0;
			}
			else{
				num=num*10+(Array[i]-'0');
			}
		}
	}
	j=5;
	while(j<=num){
		ans=ans + num/j;
		j=j*5;
		}
	printf("%lu\n", ans);
	return 0;
}