Ուղարկել | Բոլոր լուծումները | Լավագույն լուծումները | Վերադառնալ ցուցակին |
ACM_0058 - ODD AND EVEN ZEROES |
In mathematics, the factorial of a positive integer number n is written as n! and is defined as follows:
n! = 1 × 2 × 3 × 4 × · · · × (n − 1) × n
The value of 0! is considered as 1. n! grows very rapidly with the increase of n. Some values of n! are:
0! = 1 5! = 120
1! = 1 10! = 3628800
2! = 2 14! = 87178291200
3! = 6 18! = 6402373705728000
4! = 24 22! = 1124000727777607680000
You can see that for some values of n, n! has odd number of trailing zeroes (eg 5!, 18!) and for some values of n, n! has even number of trailing zeroes (eg 0!, 10!, 22!). Given the value of n, your job is to find how many of the values 0!, 1!, 2!, 3!, ... , (n − 1)!, n! has even number of trailing zeroes.
Input
Input file contains at most 1000 lines of input. Each line contains an integer n(0 ≤ n ≤ 1018).
Input is terminated by a line containing a −1.
Output
For each line of input produce one line of output. This line contains an integer which denotes how many of the numbers 0!, 1!, 2!, 3!, . . ., n!, contains even number of trailing zeroes.
Examples
№
stdin
stdout
1
2
3
10
100
1000
2000
3000
10000
100000
200000
-1
3
4
6
61
525
1050
1551
5050
50250
100126
Ավելացրեց. | Հրանտ Հովհաննիսյան |
Ամսաթիվ. | 2013-12-30 |
Ժամանակի սահմանափակումը. | 1s |
Ծրագրի տեքստի սահմանափակումը. | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Լեզուներ. | Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE |
Աղբյուրը. | SWERC 2013.F |