#include
using namespace std;
int main()
{
int t;
cin>>t;
while (t–)
{
int n;
int five = 0;
cin>>n;
int i = 5;
for (; i <=n; i=i+5)
{
int k = 0, m = i;
while (m % 5 == 0)
{
m = m / 5;
k++;
}
five += k;
}
printf("%i\n", five);
}
return 0;
}
Time Limit Exceeded, I’ve tried using scanf instead of cin but that gives me a segmentaton error(SIGSEGV), what else can I change in the code here to optimise it?