633B:A Trivial Problem

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]<<” “;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Codeforces, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s