题目链接
https://www.nowcoder.com/acm/contest/93/E
思路
其实就是找阶乘的项中5的个数
末尾为什么会出现0
因为存在5的倍数和偶数相乘 有0存在
借鉴
https://blog.csdn.net/tommyzht/article/details/46309563
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-30;
const int INF = 0x3f3f3f3f;
const int maxn = 1e9 + 5;
const int MOD = 1e9 + 7;
//
//int num[maxn], len;
//
//void init()
//{
// len = 1;
// num[0] = 1;
//}
//
//int mult(int num[], int len, int n)
//{
// ll tmp = 0;
// for (ll i = 0; i < len; i++)
// {
// tmp = tmp + num[i] * n;
// num[i] = tmp % 10;
// tmp = tmp / 10;
// }
// while (tmp)
// {
// num[len++] = tmp % 10;
// tmp = tmp / 10;
// }
// return len;
//}
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
//int Num;
//scanf("%d", &Num);
//init();
//for (int i = 2; i <= Num; i++)
//{
// len = mult(num, len, i);
//}
//int ans = 0;
//for (int i = 0; i < len; i++)
//{
// if (num[i])
// break;
// else
// ans++;
//}
//printf("%d\n", ans);
int n;
scanf("%d", &n);
int ans = 0;
for (int i = 5; ; i *= 5)
{
ans += n / i;
if (n / i == 0)
break;
}
printf("%d\n", ans);
}
}