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

if (N%2 == 1):
    print(0)
elif N == 0:
    print(0)
else:
    N //= 2
    res = 0
    div_coef = 1
    while True:
        tmp_add = N // (5 ** div_coef)
        res += int(tmp_add)
        div_coef += 1
        # print(int(tmp_add))
        if tmp_add < 1:
            break
    # print(N)
    print(int(res))

Submission status: Accepted

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

n = int(input())

a = 0

if n % 2 == 1:
    a == 0
else:
    n = n // 2
    k = 5
    while k <= n:
        a += n // k
        k *= 5

print(a)

Submission status: Accepted

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def fact_prime(n, p):
    ret = 0
    temp = p
    while(n >= p):
        ret += n // p
        p *= temp
    return ret

n = cin()

if n % 2:
    n = (n + 1) // 2
    a2 = fact_prime(2 * n, 2)
    a5 = fact_prime(2 * n, 5)
    b2 = fact_prime(n, 2) + n
    b5 = fact_prime(n, 5)
    ans = min(a2 - b2, a5 - b5)
else:
    n = n // 2
    ans = fact_prime(n, 5)
print(ans)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import os


# 検索用タグ、末尾に続く0の個数、ググる数学問題
# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())

    if n % 2 == 1:
        print(0)
        return

    ans = 0
    val = 2
    # ループ数に意味はない
    for i in range(30):
        val = val * 5
        if val > n:
            break
        ans += n // val

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1000000000000000000"""
        output = """124999999999999995"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0
for i in range(30):
    ans += N//(2*5**(i+1))
print(ans)

Submission status: Accepted

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

N //= 2
ans = 0
while N:
    ans += N // 5
    N //= 5
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = 0
if not N%2:
    s = 5
    N = N//2
    while N>=s:
        n += N//s
        s *= 5
print(n)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
if N % 2 == 0:
  f = 1
  x = N //( 2*(5**f))
  while x != 0:
    x =  N //( 2*(5**f))
    ans += x
    f += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

if N<2 or N%2:
    print(0)
else:
    import math
    ans=0
    n=N//2
    k=int(math.log(n,5))
    for i in range(1,k+1):
        ans+=n//(5**i)
        
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
if n % 2 > 0:
    print(0)
else:
    n //= 2
    c = 0
    while n > 0:
        c += n // 5
        n //= 5
    print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

res = 0
fives = 10
while True:
    if N // fives == 0:
        break
    res += N//fives
    fives *= 5
print(res)

Submission status: Accepted

Solution code:
N = int(input())
N1 = N // 10
if N % 2 == 1:
    print(0)
else:
    counter = 0
    div = 10
    while True:
        num = N // div
        if num == 0:
            break
        counter += num
        div *= 5
    print(counter)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
  print(0)
else:
  rlt = 0
  i = 10
  while N // i > 0:
    rlt += N // i
    i *= 5
  print(rlt)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
  print(0)
else:
  a = 0
  m = n // 2
  while True:
    m = m // 5
    a += m
    if m == 0:
      break
  print(a)

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
def pow_k(x, n):

    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x
def main():  #startline-------------------------------------------
    n = int(input())
    i = 0
    ans = 0
    if n % 2 == 0:
        while 10*5 ** i <= n:
            ans += n // (10* 5**i)
            i += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
if n%2 == 0:
    i = 10
    while i <= n:
        ans += n//i
        i *= 5

print(ans)

Submission status: Accepted

Solution code:

N = int(input())

if N % 2 == 1:
    print(0)
else:
    ans = 0
    div = 1
    for _ in range(100):
        div *= 5
        ans += N // (div * 2)

    print(ans)

Submission status: Accepted

Solution code:

N = int(input())

if N % 2 == 1:
    print(0)
else:
    ans = 0
    div = 10
    for _ in range(100):
        ans += N // div
        div *= 5

    print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import math
n = int(input())
cnt = 0
mod = 10
if n%2 == 1:
    print(0)
    exit()
while mod<=n:
    cnt += n//mod
    mod*=5
print(cnt)

Submission status: Accepted

Solution code:
import sys
s=0
N=int(input())
if N%2==1:
  print(0)
  sys.exit()
N=N//2
while True:
  N=N//5
  s+=N
  if N==0:
    break
print(s)

Submission status: Accepted

Solution code:
from math import ceil, log
n = int(input())
if n%2==1:
    print(0)
else:
    print(sum([n//(2*pow(5,i)) for i in range(1,ceil(log(n+1,5)))]))

Submission status: Accepted

Solution code:
def count_five(n):
    res = 0
    i = 1
    while n//pow(5,i) - n//pow(10,i)> 0:
        res += n//pow(5,i) - n//(2*pow(5,i))
        i += 1
    return res

def main(N):
    if N%2:
        return 0
    M = list(str(N))
    L = len(M)
    temp = 0
    temp2 = 0
    res = 0
    for i, n in enumerate(M[:-1], start=1):
        temp *= 10
        temp += int(n)
        res += (temp - temp2)*(L-i)
        res += count_five(temp)
        temp2 = temp
    return res

N = int(input())
print(main(N))

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    if N%2 == 1:
        print(0)
    else:
        ans = 0
        for i in range(0, 50):
            ans += N//(10*(5**i))
        print(ans)
    
if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()

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

    else:
        ans = 0
        for i in range(1, 30):
            ans += N // (2 * 5 ** i)

        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
d = 10
if n%2==1:
    print(0)
    import sys
    sys.exit()
while True:
    ans += n//d
    d *= 5
    if d>n:
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

if(N%2 != 0):
    print(0)
else:
    cnt = 0
    n = 1
    while n <= N:
        n *= 5
        if(n > N):
            break
    
        num = n*2
        cnt += N//num
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
ten_counter = 0
exp_index = math.log(10 ** 18, 5)
if n % 2 == 0:
    n //= 2
    # rangeの範囲をlogとったら if: break 不要
    for i in range(1, int(exp_index) + 1):
        if n // (5 ** i) == 0:
            break
        else:
            ten_counter += n // (5 ** i)
    # else:
    #     print("finish")
else:
    pass

print(ten_counter)

Submission status: Accepted

Solution code:
import math

n = int(input())

# nが奇数ならば必ず0
if n % 2 == 1:
    print(0)
else:
    s = 0
    p = 0
    while 10 * (5 ** p) <= n:
        s += n // (10 * (5 ** p))
        p += 1
    print(s)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
c=0
m=n/2
while m>=5:
  m/=5
  c+=1
sm=0
for i in range(c):
  sm+=(n//2)//(5**(i+1))
print(sm if n%2==0 else 0)

Submission status: Accepted

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

# In[15]:


N = int(input())


# In[16]:


ans = 0
if N%2 != 0:
    print(ans)
else:
    i = 1
    while 1:
        tmp = (5**i)*2
        if tmp <= N:
            ans += N//tmp
            i += 1
        else:
            break
    print(ans)


# In[ ]:

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

elif n % 2 == 0:
    ans = 0
    t = 10
    while n >= t:
        ans += n // t
        t *= 5
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
ans = 0
t = 10
while n >= t:
  ans += n//t
  t *= 5

if n % 2 == 0:
  print(ans)
else:
  print(0)

Submission status: Accepted

Solution code:
def solve(n):
    if n % 2 == 1:
        return 0 
    div_2 = 0
    cur = 2
    while cur <= n:
        div_2 += (n // cur)
        cur = cur * 2
    div_5 = 0
    cur = 5
    while cur <= n:
        div_5 += (n // cur) // 2
        cur = cur * 5
    return min(div_2, div_5)

n = int(input())
print(solve(n))

Submission status: Accepted

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

m = 10
a = []
b = []
while m <= n:
    a.append(n // m)
    m *= 5
    if len(a) > 1:
      b.append(a[-2] - a[-1])
if a:
    b.append(a[-1])

ans = 0
for i in range(len(b)):
    ans += (i+1)*b[i]
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    if n%2 == 1:
        print(0)
        exit(0)
    
    def count(k, n):
        now = k
        cnt = 0
        while now <= n:
            cnt += n//now
            now *= k
        return cnt

    n //= 2
    ans = count(5, n)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    if n%2 == 1:
        print(0)
        exit(0)
    
    def count(k, n):
        now = k
        cnt = 0
        while now <= n:
            cnt += n//now
            now *= k
        return cnt

    n //= 2
    cnt2 = n
    cnt2 += count(2, n)
    cnt5 = count(5, n)
    ans = min(cnt2, cnt5)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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


def resolve():
    n = int(input())
    if n % 2:
        print(0)
        exit()
    n //= 2
    res = 0
    while n:
        res += n // 5
        n //= 5
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N = int(input())
    if N % 2:
        print(0)
    else:
        ans = 0
        div = 10
        while True:
            val = N // div
            ans += val
            if not val:break
            div *= 5
        print(ans)

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    if n%2==1:
        print(0)
        return
    md = 10
    cnt = 0
    while n>=md:
        cnt += n//md
        md = md*5
    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Accepted

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


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

  if N % 2:
    print(0)
    return

  nz = 0
  i = 1
  while True:
    if N//(5**i)//2 > 0:
      nz += (N//(5**i)//2)
      i += 1
    else:
      break

  print(nz)


if(__name__ == '__main__'):
  main()

Submission status: Accepted

Solution code:
N = int(input())
n = N // 10
cnt = 0
if N % 2 == 0:
    while n != 0:
        cnt += n
        n //= 5
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
n = N // 10
cnt = 0

while n != 0:
    cnt += n
    n //= 5
print(cnt if N % 2 == 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

if n & 1:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
N = int(input())

# N:奇数ならば0
# N:偶数の場合 10が何個登場するか (素因数分解したときに2,5のペアが何個登場するか)
# 偶数の場合のみ考えているので 5 << 2と考えて5が何回登場するかを考える。
# 2で割ると(N//2)!になる
# 5 >> 2を仮定するとN//2までの5の倍数となっている数が答え。。。では無い
# 5の2乗,3乗の倍数をカウントできていないのでそれらを足す？
if N % 2 != 0:
    print(0)
    exit()

cnt = 0
current = 5
while (N // 2 >= current):
    cnt += (N // 2 // current)
    current *= 5

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

# Lv.1
#def f(t):
#    return 1 if t < 2 else t * f(t-2)
#print(f(n))

# Lv.2
# def g(p):
#     d = {2:0, 5:0}
#     for i in range(p, 1, -2):
#         t = i
#         while(t % 2 == 0):
#             t //= 2
#             d[2] += 1
#         while(t % 5 == 0):
#             t //= 5
#             d[5] += 1
#     return min(d[2], d[5])
# print(g(n))

# Lv.3
# 1,3,5,7,... 末尾は奇数
# 2,4,6,8,... Lv.2 の print(min(d[2], d[5])) は 5の方が常にmin
# 100 の時 10 で割れるのが10, 50で割れるのが2つ
# 250 の時 10 で割れるのが25, 50で割れるのが5つ, 250 で割れるのが1つ 1000個位出してみたら ? 整数分割の + - 交互のあれでは無いっぽい
k = 10
ans = 0
while k <= n:
    ans += n // k
    k = k * 5
print(ans if n % 2 == 0 else 0)

Submission status: Accepted

Solution code:
N = int(input())

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

    print(count)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
if n%2 == 1:
    print(0)
else:
    ans = 0
    tmp = 2
    dp = [0 for i in range(50)]
    for i in range(1,50):
        if tmp < 10**18:
            tmp = tmp*5
            dp[i-1]=n//tmp
        else:
            break
    for i in range(49):
        ans+=(dp[i]-dp[i+1])*(i+1)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# 41m AC
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
if n % 2 != 0:
    print(0)
    exit()
ans = 0
i = 10
while i <= n:
    ans += n // i
    i *= 5
print(ans)

Submission status: Accepted

Solution code:
# 50
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
if n % 2 != 0:
    print(0)
    exit()
ans = n // 10
i = 50
while i <= n:
    ans += n // i
    i *= 5
print(ans)

Submission status: Accepted

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ans = 0

if n % 2 == 0:
    c5 = 0
    c2 = 0
    for i in range(30,0,-1):
        c5 += i*(n//(2*5**i) - n//(2*5**(i+1)))
    for i in range(60,0,-1):
        c2 += i*(n//(2**i) - n//(2**(i+1)))
    ans = min(c5, c2)

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 % 2 == 1:
    print(0)
    sys.exit()
ans = 0
i = 1
while True:
    div = 5 ** i
    cnt = N // div
    cnt //= 2
    if cnt == 0:
        break
    ans += cnt
    i += 1
print(ans)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=5
ans=0
if n%2==1:
  print(0)
  exit()
while True:
    if a>n:
        break
    ans+=(n//a)//2
    a*=5
print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())
if n % 2 == 1:
  print(0)
  sys.exit()
ans = 0
x = 2
while n >= x:
  x *= 5
  ans += n // x
print(ans)

Submission status: Accepted

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

while True:
    d = 5**i
    if d > n//2:
        break
    else:
        ans += ((n//2) - (n//2)%d)//d
        i += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
M = 10
ans = 0

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

Submission status: Accepted

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

n, x, res = int(input()), 1, 0
if n & 1: print(0)
else:
    n //= 2
    while x < n:
        x *= 5
        res += n // x
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N % 2 == 1:
    pass
else:
    two = 0
    five = 0
    tmp = 2
    while tmp <= N:
        two += N // tmp
        tmp *= 2
    tmp = 10
    while tmp <= N:
        five += N // tmp
        tmp *= 5
    ans = min(two, five)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0
a = 10
while True:
    if N < a:
        break

    ans += N//a
    a *= 5
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    if N%2:
        print(0)
    else:
        m = N//2
        ans = 0
        t = 5
        while m >= t:
            ans += m//t
            t *= 5
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
if n%2==1:
    ans = 0
else:
    tmp = 2
    v2 = 0
    while n//tmp>0:
        v2 += n//tmp
        tmp *= 2
    v5 = 0
    tmp = 5
    nn = n//2
    while nn//tmp>0:
        v5 += nn//tmp
        tmp *= 5
    ans = min(v2, v5)
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
if n%2==1:
    print(0)
else:
    print(sum([n//(2*pow(5,i)) for i in range(1,math.ceil(math.log(n+1,5)))]))