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: Time Limit Exceeded

Solution code:
N = int(input())

###########################################
###########################################


def factorization(n):# 素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

###########################################
###########################################

    
count = N // 2        # 切り捨て除算


# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。
# 素因数分解して2と5の少ない方選べばよい。

AN5 = 0
AN2 = 0

for i in range(count):
    cal = N-i*2
    AN1 = factorization(cal)
    try:
        if AN1[0][0] == 2 :
            AN2 = AN2 + AN1[0][1]
    except:
        kari = 1
    try:
        if AN1[0][0] == 5 :
            AN5 = AN5 + AN1[0][1]
    except:
        kari = 1
    try:        
        if AN1[1][0] == 2 :
            AN2 = AN2 + AN1[1][1]
    except:
        kari = 1
    try:        
        if AN1[1][0] == 5 :
            AN5 = AN5 + AN1[1][1]
    except:
        kari = 1
    try:        
        if AN1[2][0] == 2 :
            AN2 = AN2 + AN1[2][1]
    except:
        kari = 1
    try:        
        if AN1[2][0] == 5 :
            AN5 = AN5 + AN1[2][1]
    except: 
        kari = 1


if AN2 > AN5 :
    print(AN5)
else:
    print(AN2)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
n = int(sys.stdin.readline())

def calc(num):
    a, b =0,0
    L =[1]
    for i in range(2, int(math.sqrt(num))+1):
        while num % i==0:
            L.append(i)
            num = num//i
    if num !=1:
        L.append(num)
    a +=L.count(2)
    b +=L.count(5)
    return a, b


if n%2==1:
    print(0)
else:
    c2,c5=0,0
    while True:
        a, b = calc(n)
        c2+=a
        c5+=b
        n-=2
        if n<2:
            break
    print(min(c2, c5))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(n):
    c = 0
    while n >= 1:
        if c == 0:
            s = n

        else:
            s *= n
        n = n - 2
        c += 1
    
    return s
  
if N >= 2:
  g = str(f(N))
  cc = 0
  for ii in range(len(g)):
      gi = g[len(g)-ii-1]
      if gi == '0':
          cc += 1
      
      else:
          break
  print(cc)

else:
  print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt = 0


def f(n):
    if n < 2:
        return 1
    else:
        s = n
        while n >= 3:
            s *= n - 2
            n = n - 2
        return s


for i in reversed(str(f(N))):
    if i == "0":
        cnt += 1
    else:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
    fn =1
    if n < 2:
        return 1
    else:
        while n >= 2:
            fn *= n
            n -= 2
        return fn
        


n = int(input())
fn = str(f(n))
if int(fn) % 2 == 1:
    print(0)
    exit()
n = 0
for i in range(len(fn)):
    if fn[-i-1] == '0':
        n += 1
    else:
        break
print(n)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

ans = 1
for i in range(1, N+1) :
  if i % 2 == 0 :
    ans *= i
    #print (i)

cnt = 0
s = str(ans)
for i in range(len(s)) :
  if s[len(s)-i-1] == "0" :
    cnt += 1
  else :
    break
print (cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

num = 1
for i in range(N, 0, -2):
    num = num * i
    
number = str(num)

cnt = 0
for i in range(1, len(number)+1):
    if number[-i] == '0':
        cnt += 1
    else :
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
res = 1
result = 0
for i in range(N,-1,-2):
    if(i ==0 or i == 1):
        break
    else:
        res *= i
temp = str(res)
for i in temp:
    if i == '0':
        result += 1
    else:
        if(result>0):
            result = 0
        continue

print(result)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
n = int(sys.stdin.readline())

def calc(num):
    a, b =0,0
    L =[1]
    for i in range(2, int(math.sqrt(num))+1):
        while num % i==0:
            L.append(i)
            num = num//i
    if num !=1:
        L.append(num)
    a +=L.count(2)
    b +=L.count(5)
    return a, b


c2=0
c5=0
while True:
    a, b = calc(n)
    c2+=a
    c5+=b
    n-=2
    if n<2:
        break
print(min(c2, c5))

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
ans = 0
while N > 2:
    if N % 10e+17 == 0:
        ans += 18
    elif N % 10e+16 == 0:
        ans += 17
    elif N % 10e+15 == 0:
        ans += 16
    elif N % 10e+14 == 0:
        ans += 15
    elif N % 10e+13 == 0:
        ans += 14
    elif N % 10e+12 == 0:
        ans += 13
    elif N % 10e+11 == 0:
        ans += 12
    elif N % 10e+10 == 0:
        ans += 11
    elif N % 10e+9 == 0:
        ans += 10
    elif N % 10e+8 == 0:
        ans += 9
    elif N % 10e+7 == 0:
        ans += 8
    elif N % 10e+6 == 0:
        ans += 7
    elif N % 10e+5 == 0:
        ans += 6
    elif N % 10e+4 == 0:
        ans += 5
    elif N % 10e+3 == 0:
        ans += 4
    elif N % 10e+2 == 0:
        ans += 3
    elif N % 10e+1 == 0:
        ans += 2
    elif N % 10e+0 == 0:
        ans += 1
    N = N - 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n < 10:
    print(0)
else:
    while n % 10 != 0:
        n -= 2
    total = 0
    original = 10
    while original <= n:
        total += n // original
        original *= 5
    print(total)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ans = 0
for i in range(10, a + 1, 10):
    while not i % 10:
        ans += 1
        i /= 10

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
result = 1
if(N < 2):
	result = 1
else:
	while N > 0:
		result = result * N
		N = N - 2

l = [int(x) for x in str(result)]
count = 0
for i in range(1, len(l)):
	if(l[-i] == 0):
		count = count + 1
	else:
		break
print(count)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
    if(n==0):
        n=1
    elif(n%2==0):
        for _ in range(int(n/2-1)):
            n*=n-2
    else:
        for _ in range(int((n-1)/2)):
            n*=n-2
    return n

n = int(input())

ans = 0
f=f(n)
while f > 0:
    if (f % 10 == 0):
        ans += 1
        f /= 10
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
if n%2!=0 :
    print(0)
else :
    ans=1
    i=2;
    c=0
    while i <= n :
        ans*=i
        i+=2
    p=ans%10
    ans//=10
    while p==0 :
        c+=1
        p=ans%10
        ans//=10
    print(c)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
if N<=10:
  if N==7 or N==9 or N==10:
    print(1)
    exit()
  else:
    print(0)
    exit()
if N%2==0:
  A=[2]
else:
  A=[1]
i=A[0]+2
while i<=N:
  A.append(i)
  i+=2
a=0
m=1
while len(A)!=0:
    A=[A[i] for i in range(len(A)) if A[i]%(5**m)==0]
    a+=len(A)
    m+=1
print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b


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

def f(n):
  if n < 2:
    return 1
  elif n >= 2:
    return n * f(n - 2)


n = INT()
# print@(f(n))

# while n != 1 or n != 2:
#   n = n - 2
#   print(n)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
p_l = prime_factorize(n)
two = 0
five = 0
for p in p_l:
  if p == 2:
    two += 1
  elif p == 5:
    five += 1

# print(p_l)
# print(two)
# print(five)
# exit()
# a = n // 10
# print(a)
# print(124999999999999995-a)
# b = n // 2
# c = n // 5
# print(b)
# print(c)
a = 5
a_l = []

if n % 2 == 1:
  print(0)
elif n % 2 == 0: # 偶数
# if n == 0:
#   print(1)
# if 
# elif n > 1 and n <= 5:
#   print(0)

# elif n % 2 == 0:
  a = 5
  n = n // 2
  while a <= n:
    a_l.append(a)
    a = a * 5
  # print(a_l[-1])
  # print(a_l)
  ans = 0
  for a in a_l:
    ans += n // a
  
  print(ans)
# elif n % 2 == 1:

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n % 2 == 1:
  print(0)
  
elif n < 9:
  print(0)
elif n == 10:
  print(1)
else:
  count = 0
  for i in range(10,n,10):
    
    
    while i % 5 == 0:
      count += 1
      i /= 5
   
  print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

min = 0
if (n % 2 == 0):
    min = 2
else:
    min = 3

calc = 1
for i in range(min, n + 1, 2):
    calc *= i

calc_str = str(calc)

ans = 0
for c in reversed(calc_str):
    if (c == '0'):
        ans += 1
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:



dp = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]

def func1(n):
    if n == 0: return 1
    if n == 1: return 1

    i = 2
    while i <= n:
        i_val = str(i)
        i_val = int(i_val[-1])

        ii_val = str(i-2)
        ii_val = int(ii_val[-1])


        #print(i, i_val, ii_val, dp)
        dp[i_val] = i * dp[ii_val]


        i += 1    
    #rint(dp)

    n_val = str(n)
    n_val = int(n_val[-1])
    return dp[n_val]

def func(n):
    if n == 0: return 1
    if n == 1: return 1

    i = 2
    while i <= n:
        dp.append(i * dp[i-2])
        i += 1    
    print(dp)
    return dp[n]


ans = func1(int(input()))

ans = str(ans)

last = len(ans) - 1

cnt = 0
while last >= 0:
    if ans[last] == '0':
        cnt += 1
    else:
        break

    last -= 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def suuretu(k):
    if k == 0:
        return 1
    elif k == 1:
        return 1
    else:
        fn_minus2 = 1
        fn_minus1 = 1
        for i in range(2, k+1):
            fn = i * fn_minus2
            fn_minus2 = fn_minus1
            fn_minus1 = fn
        return fn

suu = suuretu(n)
suu2 = list(str(suu))
counter = 0
for j in range(1, int(len(suu2))):
    if suu2[-j] == "0":
        counter += 1
    else:
        break
print(counter)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n % 2 == 1:
  print(0)
  
elif n < 9:
  print(0)
elif n == 10:
  print(1)
else:
  count = 0
  for i in range(10,n,10):
    
    if i % 5 == 0:
      while i % 5 == 0:
        count += 1
        i //= 5
   
  print(count)

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache

import sys

sys.setrecursionlimit(100000)

N = int(input())

cnt = 0


@lru_cache(maxsize=100000)
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)


for i in reversed(str(f(N))):
    if i == "0":
        cnt += 1
    else:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 1
for i in range (N,0,-2):
    ans = ans*i

long_ans = ans // 10
count = 0
str_ans = str(ans)
for i in range (1,long_ans+1):

    if str_ans[-i] == "0":
        count += 1
    else:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
f=1
while a>1:
    f*=a
    a-=2
i=len(str(f))-1
k=0
while str(f)[i]=="0":
    k+=1
    i-=1
print(k)

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache

import sys

sys.setrecursionlimit(500000)

N = int(input())

cnt = 0


@lru_cache(maxsize=500000)
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)


for i in reversed(str(f(N))):
    if i == "0":
        cnt += 1
    else:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache

import sys

sys.setrecursionlimit(1000000)

N = int(input())

cnt = 0


@lru_cache(maxsize=1000000)
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)


for i in reversed(str(f(N))):
    if i == "0":
        cnt += 1
    else:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

ans = 1
while n >= 2:
    ans = ans * n
    n = n - 2

count = 0
for s in reversed(str(ans)):
    if int(s) != 0:
        break
    else:
        int(s) == 0
        count += 1

print(count)

Submission status: Time Limit Exceeded

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

    cnt = 1
    power = 10**cnt
    while ans % power == 0:
        cnt += 1
        power *= 10
    
    print(cnt - 1)

Submission status: Time Limit Exceeded

Solution code:
def func2(n):
    ans = 1
    for i in range(2, n+1, 2):
        ans *= i
    return ans
    
def cnt_zero(n):
    cnt = 1
    power = 10**cnt
    while n % power == 0:
        cnt += 1
        power *= 10
    return cnt - 1
    
n = int(input())
if (n % 2) != 0:
    print(0)
else:
    f = func2(n)
    cnt = cnt_zero(f)
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def doublefactorial(n): 
    res = 1; 
    for i in range(n, -1, -2): 
        if(i == 0 or i == 1): 
            return res; 
        else: 
            res *= i; 

j=doublefactorial(int(input()))
j=str(j)
p=len(j) - len(j.rstrip('0'))
print(p)

Submission status: Time Limit Exceeded

Solution code:
def func2(n):
    ans = 1
    for i in range(2, n+1, 2):
        ans *= i
    return ans
    
def cnt_zero(n):
    cnt = 1
    power = 10**cnt
    while n % power == 0:
        cnt += 1
        power = 10**cnt
    return cnt - 1
    
n = int(input())
if (n % 2) != 0:
    print(0)
else:
    f = func2(n)
    cnt = cnt_zero(f)
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

N = int(input())

# 奇数のときは0
if N % 2 != 0:
    print(0)
    sys.exit()

R = 0
n = 2
while True:
    # 含まれる10倍数の個数だけ末尾0が増える
    n += 10
    if n > N:
        break
    R += 1

print(R)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10000000)
N = int(input())

def f(n):
    if 0 <= n < 2:
        return 1
    elif n >= 2:
        return n * f(n - 2)

fn = str(f(N))
ans = 0
for i in fn[::-1]:
    if i == "0":
        ans += 1
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

cal = 1
while n >= 2:
  cal *= n
  n -= 2
res = list(str(cal))

count = 0
for i in range(len(res)):
  if res[-i-1] == "0":
    count+=1
  else:
    print(count)
    exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = 1
ans = 0

while n > 0:
  num = num * n
  n -= 2
  
num = str(num)

for i in range(len(num)):
  if num[-1-i] == '0':
    ans += 1
  else:
    break
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def func(n):
    if n < 2:
        return 1
    else:
        return n * func(n - 2)

def func2(n):
    ans = 1
    for i in range(2, n+1, 2):
        ans *= i
    return ans

def cnt_zero(n):
    cnt = 1
    while n % (10**cnt) == 0:
        cnt += 1
    return cnt - 1

n = int(input())
if (n % 2) != 0:
    print(0)
else:
    f = func2(n)
    cnt = cnt_zero(f)
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

index = 1
ans = 0
for i in range(2, N+1, 2):
    s = str(i)
    index2 = index
    if int(s[len(s)-1:len(s)]) == 0:
        ans += 1
    else:
        index2 *= int(s[len(s)-1:len(s)])
        s2 = str(index2)
        if int(s2[len(s2)-1:len(s2)]) == 0:
            ans += 1
        else:
            index = index2


print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
total=1
for i in range(n,1,-2):
    total*=i
s=str(total)[::-1]
zeros=0
for c in s:
    if c=='0':zeros+=1
    else:break
print(zeros)

Submission status: Time Limit Exceeded

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

num = []

for _ in range(math.ceil(N/2)):
  num.append(N)
  N = N-2
  
ans = 1
for i in num:
  ans = ans*i
  
cnt = 0

for s in str(ans)[-1::-1]:
  if int(s) == 0:
    cnt += 1
  else:
    break
    
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    flg=0
    f=1
    temp=n
    while temp > 0:
        f*=temp
        temp-=2
    a=str(f)
    cnt=0
    for i in range(1,n+1):
        if a[-i] == '0':
            cnt+=1
        else:
            break
    print(cnt)
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from itertools import accumulate, repeat, takewhile
from operator import mul


def main():
    N = int(next(sys.stdin.buffer))
    if N % 2:
        print(0)
        return
    print(sum(N // x for x in takewhile(lambda x: x <= N, accumulate(repeat(5), mul, initial=10))))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
Nが奇数のとき、明らかに掛け算で10の倍数が出来上がらないので、答えは0になる。
Nが偶数のとき、掛け算に巻き込まれる5の素因数の数だけ0ができる。
5^x(1 <= x)ごとに、Nを割る。すると、0~Nに含まれる5^xの数がわかる。
そのうち半分は奇数で半分は偶数である。偶数のカウントだけを加算する。
"""

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
x = len(str(n))

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
x = len(str(n))

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


print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
x = len(str(n))

if n % 2 == 1:
  print(0)
  exit()
for i in range(1,26):
  cnt += n//((5**i)* 2)


print(cnt)

Submission status: Accepted

Solution code:

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


  print(cnt)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
I=lambda:int(input())
MI=lambda:map(int,input().split())
LI=lambda:list(map(int,input().split()))

N=I()

if N%2:
    print(0)
else:
    res=0
    i=1
    while 1:
        dr=N//(2*5**i)
        if dr:
            res+=dr
        else:
            break
        i+=1
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
i = 10
ans = 0

while  i <= n:
    ans += (n // i)
    i *= 5

print(ans if n & 1 == 0 else 0)

Submission status: Accepted

Solution code:
N = int(input())
if N & 1:
    print(0)
    exit()
    
N //= 2
cnt = 0
while N:
    cnt += N//5
    N //= 5
print(cnt)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
    else:
        N //= 2
        ans = 0
        i = 0
        while True:
            i += 1
            v = 5 ** i
            if v > N:
                break
            else:
                ans += N // v
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    if n%2 == 0:
        ans = 0
        for i in range(1,27):
            ans += n//(2*pow(5,i))
        print(ans)
    else:
        print(0)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
	print('0')
		
else:
	five = 0
	two = 0
	for i in range(1, n):
		f = n // (2*(5**i))
		t = n // (2**i)
		if f == t == 0:
			break
		five += f
		two += t
	print(min(five, two))

Submission status: Accepted

Solution code:
n = int(input())
m = n//10

f = []
while m:
    f.append(m%5)
    m //= 5

print(0 if n%2 else sum(a*(5**(i+1)//4) for i, a in enumerate(f)))

Submission status: Accepted

Solution code:
N=int(input())

if N%2==0:
    ans=0
    x=10
    while x<=N:
        ans+=N//x
        x*=5
else:
    ans=0

print(ans)

Submission status: Accepted

Solution code:
"""
Nが奇数のとき、絶対に末尾が0が来ることはない。したがって、答えは0。
Nが偶数の時、
N//10 * 1 + N//10**2 * 1 + ...の数だけ0ができる。
"""
N = int(input())
if N % 2 == 1:
    print(0)
else:
    ans = 0
    ind = 1
    while True:
        m = 5**ind
        if m > N:
            break
        r = N//m
        r //= 2
        ans += r
        ind += 1
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N%2 != 0:
  print(0)
else:
  answer = 0
  m = 10
  while m <= N:
    answer += N//m
    m *= 5
  print(answer)

Submission status: Accepted

Solution code:
def z(x):
  fives = 0
  for j in range(1, 60):
    bs = 2 * 5 ** j
    fives = fives + x // bs
  return fives
x = int(input())
print(z(x) if x % 2 == 0 else 0)

Submission status: Accepted

Solution code:
def wtf(x):
  fives = 0
  for j in range(1, 60):
    bs = 2 * 5 ** j
    fives = fives + x // bs
  return fives
x = int(input())
print(wtf(x) if x % 2 == 0 else 0)

Submission status: Accepted

Solution code:
def wtf(x):
    twos = 0
    fives = 0
    for j in range(1, 60):
        bs = 2 ** j
        twos = twos + x // bs
        bs = 2 * 5 ** j
        fives = fives + x // bs
    return min(twos, fives)
x = int(input())
print(wtf(x) if x % 2 == 0 else 0)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int):
    if N % 2 == 0:
        N = N // 2
        answer = 0
        div = 5
        while N >= div:
            answer += N // div
            div *= 5
        return answer

    else:
        return 0

    return answer


def main():
    N = int(input())
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())

ans=0

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

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
  print(0)
  exit()
ans = 0
ex = 1
while True:
  expo = 2 * 5**ex
  if n // expo == 0:
    break
  ans += n // expo
  ex += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n=int(input())


ans=0
tmp=0
p=1
if n%2==0:
    k=n//2
    while True:
        tmp =k//pow(5,p)

        ans+=tmp
        p+=1

        if tmp==0:
            break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

fives = [0]

if n % 2 == 1:
    print(0)
else:
    i = 0
    while 1:
        temp5 = (n // (5** (i +1))) //2
        if temp5 != 0:
            fives.append(temp5)
            i += 1
        else:
            break
    print(sum(fives))

Submission status: Accepted

Solution code:
n = int(input())

twoes = [0]
fives = [0]

if n % 2 == 1:
    print(0)
else:
    i = 0
    while 1:
        if n // (2 ** (i +1)) != 0:
            twoes.append(n // (2 ** (i + 1)))
            i += 1
        else:
            break
    i = 0
    while 1:
        temp5 = (n // (5** (i +1))) //2
        if temp5 != 0:
            fives.append(temp5)
            i += 1
        else:
            break
    print(min(sum(twoes), sum(fives)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def solve_function(N):
    if N % 2 == 1:
        return 0

    it_can_be_divisible = 10
    ans = 0
    while True:
        if it_can_be_divisible > N:
            break
        ans += N//it_can_be_divisible
        it_can_be_divisible *= 5

    return ans

if solve_function(N):
    print(solve_function(N))
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())

def solve_function(N):
    if N % 2 == 1:
        return 0

    n = 10
    ans = 0
    while True:
        if n > N:
            break
        ans += N//n
        n *= 5
    return ans

if solve_function(N):
    print(solve_function(N))
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())

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

n = 10
ans = 0
while True:
    if n > N:
        break
    ans += N//n
    n *= 5

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n%2!=0:
  print(0)
  exit(0)
n//=10

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = X_dumy//n
    return out

n=Base_10_to_n(n,5)
n=reversed(list(n))
tmp=1
ans=0

for i in n:
  ans+=int(i)*tmp
  tmp=tmp*5+1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n%2!=0:
  print(0)
  exit(0)
n//=10

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = X_dumy//n
    return out

n=Base_10_to_n(n,5)
n=reversed(list(n))
tmp=1
ans=0

for i in n:
  ans+=int(i)*tmp
  tmp=tmp*5+1
print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    if N % 2:
        print(0)
        return

    ans = 0
    N //= 2
    while N:
        N //= 5
        ans += N

    print(ans)
    return


if __name__ == '__main__':
    main()