# FCTRL: Getting wa

#include<math.h>
#include<stdio.h>
int main()
{
long i,j[100000],k,l,T,a,n[100000],c,sum=0,m;
scanf("%ld\n", &T);
for(c=1; c<=T; c++)
{
n[c] = 0;
}
for(i=1; i<=T; i++)
{
scanf("%ld", &j[i]);
printf(" \n");
}
for(k=1; k<=T ; k++)
{
for(l=1; j[k]>5^l; l=l+15);
a=l++;
n[k] = j[k];
while(a>0)
{
n[k] = n[k]/5^(–a);
sum = sum + n[k];
}
n[k] = sum;
}
for(m=1; m<=T; m++)
{
printf("%ld \n", &n[m]);
}
return 0;
}

^ is a XOR operator, i know, but if i use pow(5,l), then this error comes call of overloaded ‘pow(int, long int&)’ is ambiguous

Your code is not working for example input. Am I doing something wrong?

Remember, that to count the number of factors of 5(which will be the number of 0s), you can do it in linear time, by checking whether 5^i is <= N, and incrementing i. This can happen because most of the numbers can have more than 1 factor of 5 and all of them must be counted…

To have the final count, initialize a running sum variable to 0 and in each iteration increment it by: N/pow(5.0, i) which will count the factors of 5 in an iterative way…

Something like:

``````int zeros(int N)
{
double i = 1;
int sum = 0;
while(pow(5.0,i)<= N)
{
sum += N/(pow(5,i));
i++;
}
return sum;
}``````

You dont have to store the answers in arrays. It is okay if you solve the first case and print out the answer before your code reaches the second case. Secondly, try and minimize the use of math functions.
Try and remember the steps that you have done. Look at this C++ code -

``````#include<iostream>
using namespace std;
int main()
{
int j;
int test_cases;
int n;
cin >> test_cases;
while(test_cases--)
{
cin >> n;
n = n/5;
j = 0;
while(n)
{
j = j+n;
n = n/5;
}
cout << j <<"\n";
}
return 0;
}
``````
//