FCTRL: getting TLE

#include<stdio.h>
int main()
{
int a,t,k=1,sum=0;
scanf("%d",&t);
while(t–)
{
scanf("%d",&a);
while(a/pow(5,k))
{
sum+=a/pow(5,k);
k++;
}
printf("%d\n",sum);
sum=0;
k=1;
}
}
//i have submitted the above code it works fine .but i am getting “TLE” error please suggest some modifications.

You logic is correct, but however, see how redundancy is occurring in your code.

You are using, a/pow(5,k) which is being calculated twice in your code. Once while checking the while condition and other when you are calculating the value of sum. This is possibly leading to TLE verdict. Also, the range of both input and output are large and thus they’ll not fit in the range of int datatype. So, use long int or so.

Suggestion: Always when you put code, don’t put in a textual manner. Use the code sample(ctrl+K) for the same or give an ideone link.

#include
#include<math.h>
using namespace std;
int main()
{

int T,N,i,c=0;
cin>>T;
for(i=0;i<T;i++)
{
  int s=5;
 cin>>N;
 while(N/s!=1)
 {
 c=c+(N/s);
 s=s*5;
 }
cout<<c;
}
return 0;

}
then why is this showing TLE.