Problem Link

#Hint:

Number Theory

**count of trailing zero=n/5+n/(5^2)+…….until n/(5^x)==0 here x is any value for which n/(5^x) is zero;**

#Solution

#include<bits/stdc++.h>

using namespace std;

vector<int>a;

int fac(int b,int n)

{

int co=0;

for(int i=b;n/i>=1;i*=b)

{

co+=n/i;

}

return co;

}

int main()

{

int n;

cin>>n;

int i=1e6;

while(i–)

{

int k=fac(5,i);

if(k==n)

a.push_back(i);

}

cout<<a.size()<<endl;

sort(a.begin(),a.end());

for(int i=0;i<a.size();i++)

cout<<a[i]<<” “;

}

### Like this:

Like Loading...