DIGIT0 - Số 0 tận cùng
Tác giả: hieult
Ngôn ngữ: C++
#include <stdio.h>
#include <string.h>
//#include <conio.h>
int min(int a,int b)
{
if(a>b) return b;
return a;
}
main()
{
char s[10001];
int n,a[123],m=0,h=0;
gets(s);
n=strlen(s);
if(n==0)
printf("1");
else
{
for(int i=97;i<=122;i++)
{
a[i]=0;
for(int j=0;j<n;j++)
if(s[j]==("%c",i))
a[i]++;
}
int k=n;
while(k!=0)
{
k=k/5;
m+=k;
}
for(int i=97;i<=122;i++)
{
k = a[i];
while(k!=0)
{
k=k/5;
m=m-k;
}
}
k = n;
while(k!=0)
{
k=k/2;
h+=k;
}
for(int i=97;i<=122;i++)
{
k = a[i];
while(k!=0)
{
k=k/2;
h=h-k;
}
}
printf("%d",min(m,h));
}
//getch();
}