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:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    if n%2==1:
        print(0)
    else:

        def divide_count(n, p):
            """nをpで何回割り切れるか"""
        
            temp = n  # nを破壊しないため
            cnt = 0
            val = p
            m = n
            while n % p == 0:
                n //= p
                cnt += 1
            n = temp
            return cnt
        
        cnt=0
        while n>=2:
            cnt+=divide_count(n,5)
            n-=2
        print(cnt)

    
resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys

ten=0
five=0
two=0

def dic(x):
  global ten
  global five
  global two

  if x%10==0:
    ten+=1
  elif x%5==0:
    five+=1
  elif x%2==0:
    two+=1
  return 0



n=int(input())

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

while(n>1):
  
  dic(n)
  n-=2

print(min(five,two)+ten)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
if N % 2 == 1:
  print(0)
else:
  print(sum([int(math.log10(i)) for i in range(1, N + 1) if i % 10 == 0]))

Submission status: Time Limit Exceeded

Solution code:
def factorial(num):
    if num < 0:
        return 0
    result = 1
    for x in range(num, 0, -2):
        result *= x
    return result

def count_zero(num):
    a = str(factorial(num))
    i = len(a)-1
    count = 0
    while(i > 0):
        if(int(a[i]) == 0):
            count += 1
        else:
            break
        i -= 1
    return count

n = int(input())
print(count_zero(n))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ten = 0
two = 0
five = 0
while n > 1:
  if n % 2 == 0:
    two = 1
  if n % 5 == 0:
    five = 1
  if two == 1 and five == 1:
    ten = ten + 1
    
    two = 0
    five = 0
  n = n - 2
print(ten)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
from itertools import takewhile

n = int(stdin.readline().rstrip())
s = [1, 1]
for i in range(2, n+1):
    s.append(i*s[i-2])

s_r = list(reversed(str(s[-1])))
zeros = list(takewhile(lambda x: x == "0", s_r))
print(len(zeros))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
#f=nf(n-2)

count=0
if N%2==1:
    print(0)
else:
    while N%5!=0:
        if (N-2)%5==0:
            N-=2
    count+=N//10
    #print(count)
    N//=10
    while N>=5:
        count+=N//5
        #print(count)
        N//=5
    print(count)
#
"""
def f(n):
    if n>=2:
        answer=n
        n-=2
    while n>=2:
        answer*=n
        n-=2
    return answer
print(f(N))
"""

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
f_num = 0
ans = 0

if n > 0:
    f_num = 1
    for i in range(n, 0, -2):
        f_num *= i

str_f_num = str(f_num)
for i in range(1,len(str_f_num)):
    if str_f_num[-i] == '0':
        ans +=1
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
N = int(input())
count2_dict = {}
count5_dict = {}
if N % 2 != 0:
    print(0)
else:
    for i in range(2, N+1, 2):
        count2 = 0
        count5 = 0
        tmp = i
        # while tmp % 2 == 0:
        #     if tmp in count2_dict:
        #         count2 += count2_dict[tmp]
        #         break
        #     tmp = tmp / 2
        #     count2 += 1
        # count2_dict[i] = count2
        while tmp % 5 == 0:
            if tmp in count5_dict:
                count5 += count5_dict[tmp]
                break
            tmp = tmp / 5
            count5 += 1
        count5_dict[i] = count5
    print(sum(count5_dict.values()))

Submission status: Time Limit Exceeded

Solution code:
from itertools import groupby 

N = int(input())

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

def solve(N):
    if (N % 2 == 1): return 0
    
    ans = 0
    for i in range(2, N + 2, 2):
        if (i % 5 == 0):
            ans += prime_factors(i).count(5)
    return ans

print(solve(N))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = 1
ten = 0

while n >= 2:
    s *= n
    n -= 2
    while s % 10 == 0:
        ten += 1
        s /= 10

print(ten)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N % 2 != 0:
    print(0)
else:
    cnt = 0
    for i in range(10, N+1, 10):
        cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
num = 1
for i in range(2, N+1, 2):
    num *= i
    
cnt = 0
while True:
    re = num % 10
    num = num // 10
    if re != 0:
        break
    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n=input()
m=int(n)
e2=0
e5=0

while m>1:
    m2=m
    m5=m
    while m2%2==0:
        e2=e2+1
        m2=m2/2
    while m5%5==0:
        e5=e5+1
        m5=m5/5
    m=m-2

print(min(e2,e5))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list_n_ans = []
ans = []



while n >= 2:
    list_n_ans.append(n)
    n -= 2

x = len(list_n_ans)

if n % 2 == 0:
    while x > 4:
        ans.append(int(x/5))
        x = int(x/5)

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list_n_ans = []
k = 0
ans = 0

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

while n >= 2:
    list_n_ans.append(n)
    n -= 2


if n % 2 == 0:
    while len(list_n_ans) + k > 4:
        k -= 5
        x = prime_factorize(list_n_ans[k])
        y = [s for s in  x if s == 5]
        ans += len(y)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list_n_ans = [1]
k = -1
ans = 0

while n >= 2:
    list_n_ans.append(n*list_n_ans[-1])
    n -= 2


n_str = str(list_n_ans[-1])


n_str_list = list(n_str)


while n_str_list[k] == "0":
    ans += 1
    k -= 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
f_n=1
m=N//2

if N%2==0:
  for i in range(1,m+1):
    f_n*=2*i
else:
  for i in range(m+1):
    f_n*=(2*i+1)

S=str(f_n)
ans=0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

c2 = 0
c5 = 0

while 0 < n:
	m = n
	while 2 <= n and n % 2 == 0:
		if n % 2 == 0:
			n //= 2
			c2 += 1
		if n % 5 == 0:
			n //= 5
			c5 += 1
	n = m - 2

if c2 < c5:
	c10 = c2
else:
	c10 = c5

print(c10)

Submission status: Time Limit Exceeded

Solution code:
from math import floor


def main():
    result = 0
    N = int(input())
    if N % 2 == 0:
        N //= 2
        while N > 0:
            result += floor(N / 5)
            N //= N / 5
        print(result)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

N = int(input())

if N%2 != 0 : 
    print(0)
    
else : 
    global_cnt = 0
    
    for i in range(10, N+1, 10) : 
        mod = 0
        local_cnt = 0
        while(mod == 0) : 
            if i % 5 == 0 : 
                i = int(i/5)
                local_cnt += 1
            else : 
                mod = i % 5
        global_cnt += local_cnt
        
    print(global_cnt)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
counter_2=0
counter_5=0

def count_2(num):
    cnt=0
    while num%2==0:
        num//=2
        cnt+=1
    return cnt
def count_5(num):
    cnt=0
    while num%5==0:
        num//=5
        cnt+=1
    return cnt

while n>=2:
    counter_2+=count_2(n)
    counter_5+=count_5(n)
    n-=2

print(min(counter_2,counter_5))

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
sum = 1

if n % 2 == 1:
    print(0)
else:
    n = math.factorial(n//2)
    count = 0
    while n % 5 == 0:
        count+=1
        n//=5
    print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt =0
if N ==0:
    print(cnt)
elif N% 2 ==0:
    p = N//2
    num=1
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    for s in reversed(str(num)):
        if int(s) ==0:
            cnt+=1
        else:
            break 
    print(cnt)
else:
    p = (N+1)//2
    num=1
    for i in range(1,p+1):
        num = num*(2*i-1) 
    length = len(str(num))
    for s in reversed(str(num)):
        if int(s) ==0:
            cnt+=1
        else:
            break 
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt =0
num=1

if N ==0:
    print(cnt)
elif N % 2 ==0:
    p = N//2
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    for s in reversed(str(num)):
        if int(s) ==0:
            cnt+=1
        else:
            break
    
    print(cnt)

else:
    p = (N+1)//2
    for i in range(1,p+1):
        num = num*(2*i-1)
    length = len(str(num))
    for s in reversed(str(num)):
        if int(s) ==0:
            cnt+=1
        else:
            break
    
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt =0
num=1
if N ==0:
    print(0)
elif N % 2 ==0:
    p = N//2
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    if length ==1:
        print(cnt)
    else:
        for i in range(length-1,-1,-1):
            if int(str(num)[i]) !=0:
                break    
            else:
                cnt +=1
        print(cnt)
else:
    p = (N+1)//2
    for i in range(1,p+1):
        num = num*(2*i-1)
    length = len(str(num))
    if length ==1:
        print(cnt)
        
    else:
        for i in range(length-1,-1,-1):
            if int(str(num)[i]) !=0:
                break
            else:
                cnt +=1
        print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt =0
if N ==0:
    print(0)
elif N % 2 ==0:
    p = N//2
    num=1
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    for i in range(length-1,-1,-1):
        if int(str(num)[i]) !=0:
#             print(cnt)
            break
        else:
            cnt +=1
    print(cnt)
else:
    p = (N+1)//2
    num=1
    for i in range(1,p+1):
        num = num*(2*i-1)
    length = len(str(num))
    for i in range(length-1,-1,-1):
        if int(str(num)[i]) !=0:
#             print(cnt)
            break
        else:
            cnt +=1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt =0
if N ==0:
    print(0)
elif N % 2 ==0:
    p = N//2
    num=1
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    for i in range(length-1,0,-1):
        if int(str(num)[i]) !=0:
#             print(cnt)
            break
        else:
            cnt +=1
    print(cnt)
else:
    p = (N+1)//2
    num=1
    for i in range(1,p+1):
        num = num*(2*i-1)
    length = len(str(num))
    for i in range(length-1,0,-1):
        if int(str(num)[i]) !=0:
#             print(cnt)
            break
        else:
            cnt +=1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
cnt =0
if N % 2 ==0:
    p = N//2
    num=1
    for i in range(1,p+1):
        num = num*2*i
    length = len(str(num))
    for i in range(length-1,0,-1):
        if int(str(num)[i]) !=0:
            break
        else:
            cnt +=1
    print(cnt)
else:
    p = (N+1)//2
    num=1
    for i in range(1,p+1):
        num = num*(2*i-1)
    length = len(str(num))
    for i in range(length-1,0,-1):
        if int(str(num)[i]) !=0:
#             print(cnt)
            break
        else:
            cnt +=1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import re
n = int(input())
ans=0
if n % 2 !=0 or n < 10:
    print(0)
else:
    while n >= 10:
        if n % 10 ==0:
            z = re.search('0+$' , str(n))
            ans+=len(str(n)) - z.start()
            n-=10
        else:
            n-=2
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import re
n = int(input())
i=n-2
while i >= 2:
    n *= i
    i -= 2
    ans = re.search('0+$' , str(n))
print(0 if n%10 !=0 or n < 2 else len(str(n))-ans.start())

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count = 0


if N % 2 == 0:
    n = N
    sho = n // 10
    #print(sho)
    for i in range(1, sho+1):
        k = i * 10
        #print(k)
        while(k % 5 == 0 and k > 0):
            #print(k)
            k = k // 5
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt = 0
n = 1

while N // 2*(5**n) > 0:
  a = N // 2*(5**n)
  cnt = cnt + a
  n = n + 1
  
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0

N = N - int(str(N)[-1])

while True:
    if N < 10:
        break
    ans += str(N).count('0')
    N = N-10

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
c = 0
if (N % 2) == 0:
    for i in range(N,2,-2):
        for j in range(1,10):
            if i % 5**j == 0:
                c += 1
            else:
                break
    print(c)
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count5=count2=0
for i in range(N,2,-2):
  if i%5==0: count5+=1
  if i%2==0: count2+=1
print(min(count2,count5))

Submission status: Time Limit Exceeded

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

if n%2 ==0:
  for i in range(n//2):
    s = n-2*i
    while (1):
      if s%5 == 0:
        s = s//5
        five += 1
      else:
        break
  print(five)
else:
  print(0)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 1
cnt = 0

for i in range(n//2):
  a *= (n-2*i)

while (1):
  if a % 10 == 0:
    cnt += 1
    a = a//10
  else:
    break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math 
x = (1000000000000000000/2 - 1) 
print(math.factorial(x))

Submission status: Time Limit Exceeded

Solution code:
N=input()
M=int(N)
f=1
while 2<=M:
  if M<2:M=1
  f *= M
  M -= 2
B=str(f)
A=len(B)-len(B.rstrip('0'))
print(A)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
if N % 2 == 0:
    for i in range(N,2,-2):
        if i % 5 == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
fin = 1
if n%2 == 0:
    while n != 0:
        fin*=n
        n-=2
else:
    while n != 1:
        fin*=n
        n-=2
k = str(fin)
k = list(k)
p = 0
for i in k[::-1]:
    if i !="0":
        print(p)
        break
    p+=1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
temp_n = N

kaisuu = 0

if N % 2 == 1:
    print(0)
else:
    for i in range(N,1,-2):
        temp_n = i
        while temp_n % 5 == 0:
            kaisuu += 1
            temp_n = temp_n // 5

    print(kaisuu)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count = 0

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

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

Submission status: Time Limit Exceeded

Solution code:
def fab(n):
	li=[]
	ans=1
	if n<=1:
		return 1
	else :
		while n>=2:
			li.append(n)
			n-=2
		for i in li:
			ans*=i
		return ans


n=int(input())
m=str(fab(n))
i=len(m)-1
c=0
while m[i]=="0":
	c+=1
	i-=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 0
b = 0

if n % 2 != 0 or n < 10:
  print(0)
else:
  while n % 10 != 0:
    n = n-2
  
  while n >= 10:
    b = n
    while b % 10 == 0:
      a += 1
      b = int(b/10)
    else:
      n = n-10
  
  print(a)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc148/tasks/abc148_e
# TODO: timeoutを乗り越えろ
# 二重階乗になるわけで、sympy.factorial2(n)使うといけるっぽい


def main():
    num = int(input())
    count = 0
    for i in range(10, num + 1, 10):
        count += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
i = 0
while True:
    x = (2 * 5 * (5 ** i))
    if x <= N:
        ans += N // x
        i += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc148/tasks/abc148_e
# TODO: timeoutを乗り越えろ
# 二重階乗になるわけで、sympy.factorial2(n)使うといけるっぽい


def main():
    num = int(input())
    p = 0
    for i in range(num % 2, num + 1, 2):
        if i < 2:
            p = 1
        else:
            p = p * i
    count = 0
    for s in str(p)[::-1]:
        if s == "0":
            count += 1
        else:
            break
    print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# abc148_e.py
from sys import stdin
def f(n):
	sum = 1
	while n >= 2:
		sum = sum * n
		n = n - 2
	return sum
N = int(stdin.readline().rstrip())
sum = f(N)
#print(sum)
l = [int(x) for x in list(str(sum))]
l.reverse();
cnt = 0
for i in l:
	if i == 0:
		cnt = cnt + 1
	else:
		break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = [n for n in range(N, 0, -2) if n>=2]
y = 1
for i in x:
    y *= i
y = list(str(y))[::-1]
c = 0
for i in y:
    if i == "0":
        c += 1
    else:
        break
print(c)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
count = 0
answer = 1

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

answer = str(answer)
answer = list(answer)

while answer[-1] =="0":
    count += 1
    answer.pop()

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

f = 1

count5 = 0

if N < 2:
  print(0)

if N >= 2:
  if N % 2 == 0:
    while N > 0:
      if N % 5 == 0:
        count5 = count5 + 1
      N = N - 2
    print(count5)
  if N % 2 == 1:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
divisor = 10
if N % 2 == 0:
    while N >= divisor:
        ans += N // divisor
    divisor *= 5
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=0
b=0
for i in range(n):
  if n%2==0:
    a=a+1
  if n%5==0:
    b=b+1
  n=n-2
  if n<2:
    break
  
if a>b:
  print(b)
else:
  print(a)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

cnt=0

for i in range(1,19):
    cnt+=N//(10**i)

cnt+=N//100

for i in range(250,N+1,500):
    temp=i//10
    while temp:
        if temp%5==0:
            cnt+=1
        else:
            break
        temp=temp//5

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 1
  cnt = 0
  for i in range(n, 0, -2):
    if str(i)[-1] == '0':
      cnt += 1
      e = i // 10
      total *= e
    else:
      total *= i
    if str(total)[-1] == '0':
      cnt += 1
      total = total // 10    
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())

if n % 2 == 1:
    print(0)
else:
    count = 0
    k = 10
    check = 1
    t = 10
    
    while n >= t:
        t *= 5
        count += check
        check *= 5
    t = t // 5
    t += 10
    while n >= t:
        m = t
        while m % 5 == 0:
            m = m // 5
            count += 1
        t += 10
    print(count)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    a = 1

    for m in range(n, 1, -2):
        a *= m

    ret = 0
    for s in reversed(str(a)):
        if s == '0':
            ret += 1
        else:
            break

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 1
while n != 0:
  res = res * n
  n = n -2
m = str(res)
count = 0
length = len(m)
for i in range(len(m)):
  if m[length-1] == "0":
    count += 1
    length -= 1
  else:
     break
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def countZero(n):
    counter = 0
    tmp = 10
    while (tmp <= N):
        counter += 1
        tmp += 10
    return counter 
    
if(N%2!=0):
    print(0)
else:
    print(countZero(N))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
  
dp = [float("inf") for _ in range(n)]

def hoge(n):
  if n == 0:
    return 1
  if n == 1:
    return 1
  return n*hoge(n-2)

res = hoge(n)
d= 10;
cnt = 0
while(res%d == 0):
  cnt += 1
  d*=10
print(cnt)

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())

if N % 2 == 1 :
  print (0)
  exit()
  
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:
from functools import reduce
from math import factorial

N = int(input())

def func(x):
    n = x
    if n % 2 == 0:
        num = str(2 ** (n // 2) * factorial(n // 2))
        ans = len(num) - len(num.rstrip("0"))
        return ans
    else:
        return 0

print(func(N))

Submission status: Time Limit Exceeded

Solution code:

n = int(input())


def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1, 2):
        fact *= integer
    return fact

def factorization(n):
    arr = []
    temp = n
    count = 0
    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
            if i == 5:
                count += 1
    return count

print(factorization(factorial_cor(n)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 1
  cnt = 0
  for i in range(n, 0, -2):
    total *= i
    if str(total)[-1] == '0':
      cnt += 1
      total = total // 10    
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#import sys
#sys.setrecursionlimit(1000000000000)

def DF(n):
  if n < 2:
    return 1
  else:
    return n * DF(n-2)

N = int(input())
#ans = str(DF(N))
ans = 1
for i in range(N,0,-2):
  ans *= i

print(len(str(ans)) - len(str(ans).rstrip('0')))

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()

M = (N//2)//2
two = (N//2) + M*(M+1)//2

go = 0

go_dict = {}
for i in range(10, N+1, 10):
    index = i
    cnt = 0
    while index % 5==0:
        if (index//5) in go_dict:
            cnt += go_dict[index//5]+1
            break
        else:
            index /= 5
            cnt+=1
    go_dict[i] = cnt
    go += cnt


print(min(two, go))

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 i > 6 :
            break
        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:
N = int(input())

def five_func(x):
    remain = 0
    while x%5==0:
        if x == 0:
            return remain
        else:
            remain +=1
            x =x/5
    return remain


def func(N):
    flag=0
    for i in range(int(N/2)-1):
        flag += five_func(N-2*i)

    return flag

if N%2 ==1:
    print(0)
else:
    print(func(N))

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc148/tasks/abc148_e


dp = dict()


def f(n):
    if n < 2:
        return 1
    else:
        if n in dp:
            return dp[n]
        else:
            a = 0
            if n - 2 in dp:
                a = n * dp[n - 2]
            else:
                a = n * f(n - 2)
            dp[n] = a
            return a


def main():
    num = int(input())
    for i in range(num):
        f(i)
    a = f(num)
    count = 0
    for s in str(a)[::-1]:
        if s == "0":
            count += 1
        else:
            break
    print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 1
while n != 0:
  res = res * n
  n = n -2
m = str(res)
count = 0
length = len(m)
for i in range(len(m)):
  if m[length-1] == "0":
    count += 1
    length -= 1
  else:
     break
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
if n%2 == 1:
  ans = 0
else:
  for i in range(n+1):
    tmp = i
    while tmp/10 >= 1:
      tmp //= 10
      if i%10 == 0:
        ans += 1
print(ans)

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:
import sys
import math
n = int(sys.stdin.readline())

def calc(num):
    cnt=0
    while True:
        if num %5==0:
            cnt+=1
            num = num//5
        else:
            break
    return cnt


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nlist = []
while True:
    if N >= 2:
        nlist.append(N)
        N = N - 2
    else:
        nlist.append(1)
        break

a = 1
for i in nlist:
    a *= i

anumber = list(str(a))

counter = 0
for i in reversed(anumber):
    if i == '0':
        counter += 1
    else:
        break

print(counter)

Submission status: Time Limit Exceeded

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

if (N % 2 == 1):
    print (0)
    exit()
count = 0
N = N - N % 10
while N > 0:
    count += int(math.log(N, 10))
    N -= 10
print (count)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline


def get_num(n, t):
    tmp = n
    c = 0
    while True:
        if tmp % t == 0:
            c += 1
            tmp = int(tmp / t)
        else:
            break

    return c

def main():
    n = int(input()[:-1])
    l = range(n, 0, -2)

    five = 0
    two = 0
    for e in l:
        five += get_num(e, 5)
        two += get_num(e, 2)

    print(min(five, two))

main()

Submission status: Time Limit Exceeded

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

def calc(num):
    b =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 b


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

Submission status: Time Limit Exceeded

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

if (N % 2 == 1):
    print (0)
    exit()
count = 0
while N > 0:
    if (N % 10 == 0):
        count += int(math.log(N, 10))
    N -= 2
print (count)