求n!后面有多少个0
#include<iostream>
using namespace std;
int func(int n)
{
long long res=1;
int count=0;
int temp;
while(n>0)
{ temp=n;
while(temp%10==0)
{
count++;
temp=temp/10;
}
res=res*temp;
while(res%10==0)
{
count++;
res=res/10;
}
while(res/1000!=0)
{
res=res%100;
}
if(n%2==0&&(n-1)%5!=0)
n=n-1;
n=n-1;
}
return count;
}
int main()
{
int n;
while(cin>>n)
{
if(n<=0)
cout<<0<<endl;
else
cout<<func(n)<<endl;
}
return 0;
}