#GL0000173. Số chữ số 0 tận cùng của giai thừa theo cơ số (Trailing Loves (or L'oeufs?))
Bài tập thuộc lộ trình
Mục lục đề ⌄
Số chữ số 0 tận cùng của giai thừa theo cơ số (Trailing Loves (or L'oeufs?))
Trailing Loves (or L'oeufs?)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
The number of trailing zero digits of an integer depends on the numeral base. For instance, has one trailing zero in decimal notation, while its binary representation has three trailing zero digits.
Given integers and , find the number of consecutive trailing zero digits in the base- representation of , where . A single trailing zero means divisibility by ; two trailing zeros mean divisibility by , and so on.
Print the number of zeros; do not construct the factorial or its base- representation.
Input
One line containing two integers and .
Output
Print one nonnegative integer: the number of trailing zeros of in base .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
6 9
Output
1
Explanation
, which has exactly one trailing zero.
Example 2
Input
5 2
Output
3
Explanation
ends with three zero digits.