PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000207. Chữ số 0 cuối của tổ hợp nhân lũy thừa (Trailing Zeroes (II))
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 tổ hợp nhân lũy thừa (Trailing Zeroes (II))
Trailing Zeroes (II)
Source: LightOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers with , consider
$$A=C(n,r)\cdot p^q,\qquad C(n,r)=\frac{n!}{r!(n-r)!}.$$Find the number of trailing zero digits in the decimal representation of . The integer may be too large to store directly; only its trailing-zero count is required.
Input
The only line contains four integers in that order.
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
10 4 1 1
Output
1
Explanation
and , so . Its decimal representation has one trailing zero. Equivalently, provides at least one factor and exactly one factor , while adds no prime factors.