PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000215. Chữ số 0 cuối của giai thừa kép (Double Factorial)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chữ số 0 cuối của giai thừa kép (Double Factorial)
Double Factorial
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Define for nonnegative integers by
$$f(n)=\begin{cases}1,&0\le n<2,\\n\cdot f(n-2),&n\ge2.\end{cases}$$Thus is the product of positive integers with the same parity as , starting at and decreasing in steps of .
Given , find the number of trailing zero digits in the decimal representation of .
Input
The only line contains the integer .
Output
Print one integer: the number of trailing zeros of .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
12
Output
1
Explanation
The factors are , so , which has one trailing zero. Equivalently, and the exponent of in is . Thus the answer is .