Problem:


Score : 500 points

Problem Statement

For an integer n not less than 0, let us define f(n) as follows:

f(n) = 1 (if n < 2)

f(n) = n f(n-2) (if n \geq 2)

Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Constraints

0 \leq N \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of trailing zeros in the decimal notation of f(N).

Sample Input 1

12

Sample Output 1

1

f(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.

Sample Input 2

5

Sample Output 2

0

f(5) = 5 × 3 × 1 = 15, which has no trailing zeros.

Sample Input 3

1000000000000000000

Sample Output 3

124999999999999995



Sample input:
12


Sample output:
1

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
i = 1
if (N % 2 == 1):
    k = (N + 1) // 2
    while (5**i <= k):
        ans -= k // (5**i)
        i += 1
    i = 1
    while (5**i <= 2*k):
        ans += k // (5**i)
        i += 1
else:
    k = N // 2
    while (5**i <= k):
        ans += k // (5**i)
        i += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
s = 10
if n % 2 == 0:
    while True:
        x = n // s
        ans += x
        if x != 0:
            s *= 5
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
if n % 2 == 1:
  print(0)
  quit()
if n == 0:
  print(0)
  quit()

l = int(math.log10(n))+1
cnt = 0
for i in range(1,10*l):
  cnt += (n // 5 ** i) // 2
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
m = n//2
ans = 0
if n%2==1:
    print(0)
else:
    for j in range(1,100):
        ans += m//(5**j)
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def f(n):
    if n <= 1:
        return 1
    else:
        return n * f(n-2)
    
# for i in range(100):
# for i in [90, 100, 140, 150, 160, 200, 1240, 1250, 1250, 1260]:
#     print(i, f(i))

N = INT()

A = []
i = 0
while 5 ** i <= 10 ** 18:
    A.append(5**i * 10)
    i += 1

if N % 2 == 0:
    ans = 0
    for a in A:
        ans += N // a
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
n=int(input())

ans = 0
if n % 2 == 1:
    print(0)
else:
    while n // 5 >= 1:
        division_tmp = n // 5
        n = division_tmp
        ans += division_tmp // 2
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 != 0:
    print(0)
    exit()
ans = 0
d = 2
while d < N:
    d *= 5
    ans += N // d
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
if n % 2 == 1:
    print(0)
    exit()

res = 0
x = 10
while x <= n:
    res += n // x
    x *= 5
print(res)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n%2==1:
  ans=0
else:
  j=n
  for i in range(1,50):
    k=(5**i)*2
    j=(j-j%k)
    ans+=j//k
print(ans)

Submission status: Accepted

Solution code:
n = int(input().strip())

fn=n//2+1
ans=0
if n%2 == 0: # even
    tmp=5
    while tmp<=fn-1:
        ans+=(fn-1)//tmp
        tmp*=5
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
  print(0)
else:
  k=10
  ans=0
  while n>=k:
    ans+=n//k
    k*=5
    #print(ans, k)
    
  print(ans)

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    N = int(input())
    if N == 0 or N == 1:
        print(0)
        return

    if N % 2 == 1:
        print(0)
        return
    else:
        N //= 2
        n5 = 0
        i = 1
        while 5**i <= N:
            n5 += N // (5**i)
            i += 1

        print(n5)
        return

    # print(min(n2, n5))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
    print(0)
else:
    c=0
    i=0
    while True:
        i+=1
        c+=int(n//((5**i)*2))
        #print((5**i)*2,c)
        if int(n//(5**i))==0:
            break
        #i+=1 
    print(c)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2:
    print(0)
else:
    n = n // 10
    ans = n
    c = 5
    while True:
        if n // c:
            ans += n // c
            c *= 5
        else:
            break
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1:
  print(0)
else:
  n=N//2
  A=n
  a=0
  b=0
  while A>=5**a:
    a+=1
  while A>=2**b:
    b+=1

  cntfive=0  
  cnttwo=0
  for i in range(1,a):
    cntfive+=n//(5**i)
  for j in range(1,b):
    cnttwo+=n//(2**j)

  ans=min(cntfive,cnttwo+n)
  print(ans)

Submission status: Accepted

Solution code:
import sys

n=int(input())

if n%2==1:
    print(0)
    sys.exit()

ans = 0
a=10

for i in range(1000):
    ans += n//a
    a*=5

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()

if n < 10:
    print(0)
    quit()

if n % 2:
    print(0)
    quit()

else:
    ans = n//10
    tmp = 10
    cnt = 0
    while n//tmp > 0:
        tmp = (tmp//2)*10
        ans += (n//tmp)
        cnt += 1
        
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n%2==1:
  print(0)
else:
  for i in range(1,30):
    ans+=n//(5**i*2)
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n%2==1:
    print(0)
else:
    ans = n//10
    k = 1
    n = n//10
    while 5**k <= n:
        ans += n//(5**k)
        k+=1
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
    exit()
else:
    ans = 0
    keta = 1
    while n >= (5**keta):
        ans += (n // (5**keta))//2
        keta += 1
    keta = 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
n10 = n
n5 = n//10
ans += n5

if n%2 == 1:
    ans = 0
else:
    for i in range(50):
        n5 = n5 // 5
        ans += n5
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
y = 0
if n % 2 == 0:
    for i in range(1, n):
        k = (5**i) * 2
        if n >= k:
            y += n // k
        else:
            break
    print(y)
else: print(0)

Submission status: Accepted

Solution code:
N = int(input())
def zero(N):
    if N % 2 == 1:
        return 0
    else:
        return zero2(N)
def zero2(N):
    m = N//2
    n = 0
    i = 1
    while (5 ** i) <= m:
        n = n + (m //(5 ** i))
        i = i + 1
    return n
print(zero(N))

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 0
    n //= 2
    frac = 1
    for i in range(1, 26):
        frac *= 5
        ans += n // frac
    print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

if n % 2 == 1:
  print(0)
else:
  ans = 0
  for i in range(1, 100):
    ans += n // (2 * 5 ** i)
  print(ans)

Submission status: Accepted

Solution code:
n=int(input())

if(n%2 == 1):
    print(0)
else:
    mod=10
    ans=0
    while(n >= mod):
        ans+=n//mod
        mod*=5
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 0:
    tab = [None] * 32
    pow5 = 10
    for s_tab in range(1, 32):
        if pow5 > N:
            tab[s_tab] = 0
            break
        else:
            tab[s_tab] = N // pow5
            pow5 *= 5
    #
    # print("#", tab)
    ans = 0
    cnt = 0
    for j in range(s_tab):
        i = s_tab - j
        #
        cnt_tmp = tab[i] - cnt
        ans += i * cnt_tmp
        cnt += cnt_tmp
    #
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
from decimal import *

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    count=0
    if n%2==1:
        print(0)
    else:
        for i in range(1,30,1):
            b=n//(2*(5**i))
            count+=b
        print(count)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
from math import log
n = int(input())
if n % 2 == 1 or n == 0:
    print(0)
else:
    m = n // 2
    total = 0
    for p in range(1, int(log(m, 5)) + 1):
        total += m // (5 ** p)
    print(total)

Submission status: Accepted

Solution code:
N = int(input())
x = 0
xx = 10
for i in range(1, 10*10, 1):
    x += N//xx
    xx = xx*5
if N % 2:
    print(0)
else:
    print(x)

Submission status: Accepted

Solution code:
n = int(input())
r = 0
if n %2 == 0:
    while n >= 5:
        r += (n//5)//2
        n //=5
    print(r)
else:
    print(0)

Submission status: Accepted

Solution code:


N = int(input())

if N % 2 == 1:
    print(0)
else:
    xxx = N // 10
    for i in range(25):
        xxx += (N // (10 * 5 ** (i+1)))
    print(xxx)

Submission status: Accepted

Solution code:
N = int(input())
A = 0
a = 1
if(N % 2 == 0):
  for i in range(100000):
    a *= 5
    A += N // (a*2)
    if(N//a == 0):
      break
  print(A)
else:
  print(0)

Submission status: Accepted

Solution code:
n=int(input())
sum=0
if n%2==0:
    a=n
    while a>0:
        a=a//5
        sum+=a//2
print(sum)

Submission status: Accepted

Solution code:
import sys
n=int(input())
if n%2==1:
    print(0)
else:
    a=n//2
    count=0
    i=1
    while(True):
        b=a//(5**i)
        if b == 0:
            break
        else:
            count+=b
            i+=1
    print(count)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
    exit()

num = 0
five = 0
N_5 = N // 2

while(True):
    if N_5 >= 5:
        N_5 = N_5 // 5
        five += 1
    else:
        break

N = N // 2

for i in range(1, five+1):
    f = 5 ** i
    num += N // f

print(num)

Submission status: Accepted

Solution code:
def sarch(n, l):
    a = n * 10 + 5
    b = n * 10
    if l - 1 > 0:
        ans = sarch(a, l - 1)
        ans += sarch(b, l - 1)
    else:
        ans = 0
    # print(a, b)
    while n % 5 == 0 and n > 0:
        # print(n, 2)
        ans += 1
        n //= 5
    # print(n)
    return ans

n = int(input())
if n % 2 == 0:
    ans = 0
    tmp = 10
    while tmp <= n:
        ans += n // tmp
        tmp *= 5
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 != 0:
    print(0)
else:
    ans = N // 10
    k = 50
    while k <= N:
        ans += N // k
        k *= 5
    print(ans)

Submission status: Accepted

Solution code:
def p_e():
    n = int(input())
    if n & 1 == 1:
        print(0)
        exit()
    ans = n // 10
    x = 50
    while x <= n:
        ans += n // x
        x *= 5
    print(ans)
    
p_e()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    if n%2 == 1:
        print(0)
    else:
        ans = 0
        for i in range(1,19):
            ans += n//10**i
        for i in range(1,51):
            ans += n//(10*(5**i)) - n//(10*(5**i)*(2**i))
        print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
xx = 10
if (N % 2 != 1):
  for i in range(1, 10*10):
    ans += N // xx
    xx = xx*5
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N == 0 or N == 1:
    print(0)
    exit()

if N % 2 == 1:
    print(0)
    exit()

answer = 0
cnt = 1
while 5 ** cnt * 2 <= N:
    answer += N // (5 ** cnt * 2)
    cnt += 1

print(answer)

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
    N = 0
else:
    N//=10
c=N

while N//5 !=0:
    N = N//5
    c +=N
    
print(c)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
k = 10
if n%2 != 0:
  print(0)
else:
  while k<=n:
    tmp = n//k
    ans += tmp
    k *= 5
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 == 1:
  print(0)
  exit()
two = 2
two_cnt = 0
while two <= N:
  two_cnt += (N // two)
  two *= 2
five = 5
five_cnt = 0
while five <= N:
  five_cnt += (N // five) // 2
  five *= 5
#print(two_cnt,five_cnt)
print(min(two_cnt,five_cnt))

Submission status: Accepted

Solution code:
n = int(input())
if n & 1:
    print(0)
else:
    fac = n // 2
    count = 0
    i = 5
    while fac // i >= 1:
        count += fac // i
        i *= 5
    print(count)

Submission status: Accepted

Solution code:
num = int(input())

if num % 2 == 0:
    divider = [2 * (5 ** x) for x in range(1, 25+1)]
    ans = 0
    for d in divider:
        ans += num // d
    print(ans)

else:
    print(0)

exit(0)

Submission status: Accepted

Solution code:
n = int(input())

def count5(j):
    if j % 5 != 0:
        return 0
    return count5(j // 5) + 1

if n % 2 == 0:
    i = 2
    v = 1
else:
    print(0)
    exit()

c5 = 0
j = 0

m = n // 2

v5 = 5
while v5 <= m:
    c5 += (m // v5)
    v5 *= 5

print(c5)

Submission status: Accepted

Solution code:
import math
N = int(input())

k = 0
if N%2 ==0:
  n = N//2
  i = 5
  while n >= i :
    k += n //i
    i *= 5

print(k)

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
    print(0)
else:
    k=n//2
    ans=0
    i=1
    while i<=k:
        i*=5
        ans+=k//i
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N%2 != 0:
    print(0)
    exit()

a = 1
ans = 0
flag = True
while (N >= 2*5**a) :
    ans += N//(2*5**a)
    a += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 0:
    N = N // 2
    cnt = 0
    for i in range(1, 27):
        cnt += N // (5 ** i)
    print(cnt)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
m = n//10
s=0
for i in range(50):
    s=s+(m//5**(i+1))
    #print(s)
if n%2==1:
    print(0)
else:
    print(s+n//10)

Submission status: Accepted

Solution code:
N = int(input())

x = 0
xx = 10
for i in range(1, 10*10, 1):
    x += N//xx
    xx = xx*5
    
if N%2:
    print(0)
else:
    print(x)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(40):
        a = 10 * (5 ** i)
        ans += N // a

    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

t = 50
w = []
while True:
    x = N // t
    if x == 0:
        break
    else:
        w.append(x)
    t *= 5

if N % 2 == 1:
    ans = 0
else:
    ans = N // 10
    for wi in w:
        ans += wi
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
result = 0
if x % 2 != 0:
  print(result)
else:
  i = x // 2
  while(i>4):
    i = i // 5
    result += i
  print(result)

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    n=int(input())
    nn=n//2
    a=nn//5 #base
    b = [a//(10**i) for i in range(1,18)]
    c = [a//(5**i) for i in range(1,50)]
    count=0
#    for i in b:
 #       if i!=0:
  #          count+=i
    for i in c:
        if i!=0:
            count+=i
 #   print(b,c)
    if n%2==0:
        print(count+a)
    else:
        print(0)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import copy
n = int(input())
m = copy.copy(n)

if n % 2 == 1:
    print(0)
else:
    ans = 0
    m //= 5

    while n > 4:
        ans += (n // 5)//2
        n //= 5
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
    print(0)
    quit()

x = N
fives = 0
while x:
    x //= 5
    fives += (x//2)
    # print(x, fives)
    
print(fives)

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
  print(0)
else:
  N = N//2
  num = 0
  while N>0:
    N = N//5
    num += N
    
      
  print(num)

Submission status: Accepted

Solution code:
import sys

n = int(input())

if n % 2 == 1:
    print(0)
    sys.exit()

n //= 10
sub_zero = n

for i in range(1, 30):
    sub_zero += n // (5**i)

print(sub_zero)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    N //= 10
    ans = 0
    for i in range(1, 40):
        ans += N // (5 ** i)
    print(ans + N)

Submission status: Accepted

Solution code:
N = int(input())


# def f(n):
#     if n < 2:
#         return 1
#     return n * f(n - 2)

if N % 2 != 0:
    print(0)
    exit()

A = [0] * 30
m = 5
for i in range(1, 30):
    A[i] = N // m
    m *= 5
print(sum([a // 2 for a in A]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
if N%2==1:
    print(0)
    exit()
res = 0
M = N//2
a=0
b=0
for keta in range(1,54):
    tmp = M//(2**keta)
    a += tmp
    tmp = M//(5**keta)
    b += tmp

print(min([a,b]))

Submission status: Accepted

Solution code:
from sys import stdin
f_i = stdin

N = int(f_i.readline())

if N % 2 == 1:
    ans = 0
else:
    ans = 0
    d = 5
    while d < N:
        num = N // d
        num //= 2
        ans += num
        d *= 5

print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
if n <= 9 or n % 2 == 1:
  print(0)
  quit()
r = n // 10

for j in range(1, 25):
  r += n // ((5 ** j) * 10)

print(r)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 0:
    ans = 0
    for x in range(1, 28):
        ans += N // (2*5**x)
    print(ans)

else:
    print(0)


def function(x):
    if x < 2:
        return 1
    else:
        return x * function(x - 2)

Submission status: Accepted

Solution code:
n = int(input())
if n%2 == 1:
    print(0)
else:
    counter = 0
    for i in range(1, n):
        num = n/pow(5, i)
        if num >= 1:
            counter += (n//pow(5, i))//2
        else:
            break
    print(counter)

Submission status: Accepted

Solution code:
N = int(input())

if N & 1:
    print(0)
else:
    i = 1
    ans = 0
    while True:
        t = N // 2 // (5 ** i)
        if t == 0:
            break
        ans += t
        i += 1
    print(ans)

Submission status: Accepted

Solution code:
import sys
n=int(input())
if n%2==1:
  print(0)
  sys.exit()

tmp=[5**i*2 for i in range(1,30)]
tmp1=[n//tmp[i] for i in range(29)]
print(sum(tmp1))

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
    print(0)
else:
    ans = 0
    ans += n // 10
    n = n // 10
    for i in range(100):
        ans += n // 5
        n = n // 5
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if(n & 1):
	print(0)
else:
	ans = n // 10
	cur = 5
	n = n //10
	while(cur <= n):
		ans += (n//cur)
		cur = cur * 5
	print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    N = N//2
    ans = 0
    while N > 0:
        N = N // 5
        ans += N
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N & 1 == 1:
    print(0)
    exit()

N >>= 1

five_count = 5

ans = 0

while five_count <= N:
    ans += N // five_count
    five_count *= 5

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
from decimal import Decimal
#d = Decimal('1.1')
N=int(input())
N=Decimal(N)
if N%2!=0:
    print(0)
else:
    ans=0
    for i in range(1,27):
        ans+=int((N//Decimal(5**i)/2))
    print(Decimal(ans))

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
    print(0)
else:
    count=0
    #count2=0
    for i in range(1,100):
        #count+=(n//(5**i))
        count+=(n//((5**i)*2))
    print(count)

Submission status: Accepted

Solution code:
def dobfac(num):
    count = 0
    i = 5
    if num % 2:
        print(0)
    else:
        while num / i > 0:
            count += num // i // 2
            i *= 5
        print(count)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    dobfac(int(in_str[0]))

Submission status: Accepted

Solution code:
def count (x):
    i = 5
    zeros = 0
    while x >= i:
        zeros += x // i
        i *= 5
    return int(zeros)
  

n = int(input())
if n % 2 != 0:
    print(0)
else:
    n = n // 2
    print(count(n))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()

	if N % 2 == 1:
		print(0)
		sys.exit()

	ans = 0
	base = 10
	while True:
		if base > N:
			break

		tmp = N // base
		ans += tmp
		base *= 5

	#nene = N // 10
	#manaka = N // 50
	#rinko = N // 250

	#tmp2 = goo(N)
	#print(tmp2)
	#print(nene)
	#print(manaka)
	#print(rinko)
	print(ans)

def goo(val):
	if val < 2:
		return 1
	else:
		bbb = goo(val-2)
		aaa = val * bbb
		#print("{} x {}".format(val,bbb))
		return aaa

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
    print(0)
else:
    ans = 0
    i = 0
    while 10*(5**i)<=N:
        i+=1
    for j in range(i):
        ans+=N//(10*(5**j))
    print(ans)

Submission status: Accepted

Solution code:
a=int(input())
sd=10
count=0
if a%2==0:
    for i in range(100):
        count+=a//sd
        sd*=5
    print(count)
else:
    print("0")

Submission status: Accepted

Solution code:
n = int(input())
fivenum = 0

if n%2 == 1:
  print(0)
else:
  for i in range(1000):
    j = 2*pow(5,i+1)
    if j <= n:
      fivenum += n//j
  print(fivenum)

Submission status: Accepted

Solution code:
n = int(input())

if n%2 == 1:
	print(0)
else:
	now = 5
	cnt = 0
	while now < n:
		cnt += n//(now*2)
		now = now*5
	print(cnt)

Submission status: Accepted

Solution code:
from fractions import gcd

def read():
    N = int(input().strip())
    return N,


def list_multiple_of_5(n):
    base = []
    mul = 5
    while mul <= n:
        base.append(mul)
        mul *= 5
    return base

def solve(N):
    if N % 2 == 1:
        return 0
    count = 0
    base10 = N // 10
    count += base10
    m5s = list_multiple_of_5(base10)
    for m5 in m5s:
        count += (base10 // m5)
    return count


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Accepted

Solution code:
N = int(input())
# 愚直に求めるならば
# f(n) = n(n-2)(n-4)...(n%2+4)(n%2+2)f(n%2)

if N % 2:
    print(0)
    exit()
# n が奇数ならば0を出力すればよい

# nが偶数ならば
# f(n) = n(n-2)(n-4)...(n%2+4)(n%2+2)

# 小問題
# n , n-2, n-4, ... , n%2+4, n%2+2
# の中に含まれるNの倍数の数を求めよ
def a(n,N):
    n -= n % (2 * N)
    return n // N // 2

s = 0
result = 1
NN = 5
while result:
    result = a(N,NN)
    s += result
    NN *= 5

print(s)

Submission status: Accepted

Solution code:
import sys
n = int(input())
ans = 0
i = 10
if n%2:
    print(0)
    sys.exit()

while True:
    if i > n:
        break
    ans += n//i
    i *= 5
print(ans)

Submission status: Accepted

Solution code:
import sys

s = input()
n = int(s)

if n % 2 != 0:
  print(0)
  sys.exit(0)

count = 0
index = 5
while index <= n:
  count += (n // index) //2
  index *= 5
  
print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

if n%2 == 1:
    print(0)
else:
    cnt = 0
    tmp = 10
    while(tmp <= n):
        cnt += n//tmp
        tmp *= 5
    print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
if n < 2:
    print(0)
    exit()

if n % 2 != 0:
    print(0)
    exit()

ans = 0
a = 10
for i in range(10**18):
    if 10*5**i > n:
        break
    ans += n//(10*5**i)
print(ans)

Submission status: Accepted

Solution code:
import math


def solve_even(n):
    assert(n % 2 == 0)
    k = n // 2
    return leg(k)


def leg(k):
    return sum(k // 5 ** i for i in range(1, int(math.log(k) / math.log(5)) + 1))


n = int(input())

if n % 2 == 0:
    if n == 0:
        print(0)
    else:
        print(solve_even(n))
else:
    if n == 1:
        print(0)
    else:
        print(solve_even(n + 1) - leg(n // 2 + 1))

# (2k + 1)!! = (2k + 2)! / (2^(k+1)*(k+1)!)

Submission status: Accepted

Solution code:
def solve(n):
    if n % 2 == 1:
        return 0
    else:
        m = n // 2
        res = 0
        while m > 0:
            m = m // 5
            res += m
        return res


def main():
    n = int(input())
    res = solve(n)
    print(res)


def test():
    assert solve(12) == 1
    assert solve(5) == 0
    assert solve(1000000000000000000) == 124999999999999995


if __name__ == "__main__":
    test()
    main()

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    count = 0
    for i in range(1, 27):
        count += N // (5**i*2)
    print(count)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n=int(input())
	
	if n%2==1:
		print(0)
		exit(0)
	else:
		ans=0
		for i in range(1,36):
			ans+=n//(2*(5**i))
		print(ans)




	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 == 1:
  print(0)
else:
  ans = 0
  for i in range(100):
    ans += (N // 10) // (5 ** i)
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
    exit()
time_5 = 1
cnt = 0
while time_5 < n:
    cnt += 1
    time_5 *= 5    
ans = 0
for i in range(1, cnt):
    mod_10 = n // (5 ** i * 2)
    ans += mod_10
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    ans = 0
    d = 10
    while True:
        ans += N // d
        d *= 5
        if N < d:
            break
    print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    if n % 2 != 0:
        print(0)
        return 0
    cnt5 = 0
    n = n//2
    for i in range(1, 36):
        cnt5 += (n//5)
        n //= 5
    print(cnt5)


main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    if N % 2 == 1:
        print(0)
        exit()

    r = N // 2
    c = 0
    while r >= 5:
        c += r // 5
        r //= 5

    print(c)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
  print(0)
else:
  ans = 0
  M = 10
  while(M<=N):
    ans += N//M
    M *= 5
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    res_two = 0
    res_five = 0
    for i in range(1, 100):
        if N // (2 ** i) == 0:
            break
        res_two += N // (2 ** i)
    for i in range(1, 100):
        if N // (5 ** i) == 0:
            break
        res_five += N // (5 ** i) // 2
    print(min(res_two, res_five))

Submission status: Accepted

Solution code:
n=int(input())
z=1
a=0
if n%2==0:
  for i in range(100):
    z*=5
    if n<z:
      break
    t=n//z
    a+=(t-int(t%2==1))//2
  print(a)
else:
  print(0)

Submission status: Accepted

Solution code:
N = int(input())
output = 0
X = 0
if N%2==1:
    output = 0
else:
    for i in range(1,30):
        X = N//(5**i)
        output = output + (X//2)
print(output)

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1:
  print(0)
else:
  a=len(str(N))
  counter=0
  i=5
  while N>=i:
    x=N//i
    x//=2
    counter+=x
    i*=5
  print(counter)

Submission status: Accepted

Solution code:
N = int(input())
if N %2 == 1:
    print(0)
    exit()

# print(N//10)

# result = 0
# for i in range(19):
#     print(N//(10**(i+1)))
#     result += N//(10**(i+1))

# print(result)

result = 0
for i in range(100):
    # print(N//((5**(i+1))*2))
    result += N//((5**(i+1))*2)
print(result)

Submission status: Accepted

Solution code:
N = int(input())

num = 10
ans = 0
if N % 2 == 1:
    print(0)
else:
    while(num <= N):
        ans += N // num
        num *= 5
    print(ans)