fctrl why is my code overtime

#include
#include

using namespace std;

long num_of_zeroes(long n)
{long s=0;int flag=1;
long d=5;long p;
while(flag)
{if (d>n)
flag=0;
else
{
p=d;
for(p;p<=n;p+=d)
++s;d*=5;
}

}

return (s);
}

int main()
{long a[100000];
long t;
cin>>t;cout<<endl;
for (int i=0;i<t;++i)
{cin>>a[i];cout<<endl;
}

system(“cls”);

for(int j=0;j<t;++j)
{
cout<<num_of_zeroes(a[j])<<endl;
}
return 0;

}

/how can this be time limit exceeded i just tested on my dev c++ its jus 0.013 seconds for 6 cases as in sample input?

Do not use system calls

system("cls")

Why are you printing those new lines?

cin="">>a[i]; cout<<endl;
2 Likes

thanx man btw this was my first post to this site ever …do u mind givin som pointers on submittin probems at such a competetitive site

ne other faster console io than cin and cout for c++
my compiler is dev c++ i don know the version of c++ but most probably gcc 3.4.2

btw jus fyi my code is still displayin tym limit exceeded

even if you are using C++, do not use cin and cout, you can read more in FAQ - http://www.codechef.com/wiki/faq#Why_do_I_get_a_Time_Limit_Exceeded