QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#5344. 奇偶零

Estadísticas

在数学中,正整数 $n$ 的阶乘记作 $n!$,定义如下:

$$n! = 1 \times 2 \times 3 \times 4 \times \dots \times (n - 1) \times n = \prod_{i=1}^{n} i$$

规定 $0! = 1$。随着 $n$ 的增大,$n!$ 的增长非常迅速。以下是一些 $n!$ 的值:

$0! = 1$ \quad $5! = 120$ $1! = 1$ \quad $10! = 3628800$ $2! = 2$ \quad $14! = 87178291200$ $3! = 6$ \quad $18! = 6402373705728000$ $4! = 24$ \quad $22! = 1124000727777607680000$

可以看出,对于某些 $n$ 值,$n!$ 末尾零的个数为奇数(例如 $5!, 18!$),而对于另一些 $n$ 值,$n!$ 末尾零的个数为偶数(例如 $0!, 10!, 22!$)。给定一个整数 $n$,你的任务是求出在 $0!, 1!, 2!, 3!, \dots, n!$ 这些数中,有多少个数末尾零的个数为偶数。

输入格式

输入文件包含最多 1000 行。每行包含一个整数 $n(0 \le n \le 10^{18})$。输入以包含 $-1$ 的行结束。

输出格式

对于每一行输入,输出一行。该行包含一个整数,表示在 $0!, 1!, 2!, 3!, \dots, n!$ 中,有多少个数末尾零的个数为偶数。

样例

输入 1

2
3
10
100
1000
2000
3000
10000
100000
200000
-1

输出 1

3
4
6
61
525
1050
1551
5050
50250
100126

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.