305944: CF1114C. Trailing Loves (or L'oeufs?)
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Trailing Loves (or L'oeufs?)
题意翻译
给定一个$n~(n \leq 1e18)$,求$n!$在$b~(b \leq 1e12)$进制下,末尾$0$的个数。 其中$n!=\prod \limits_{i=1}^{n}i$题目描述
The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $ 9200 $ has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is. However, Aki believes, that the number of trailing zeros of a number is not static, but depends on the base (radix) it is represented in. Thus, he considers a few scenarios with some numbers and bases. And now, since the numbers he used become quite bizarre, he asks you to help him to calculate the beauty of these numbers. Given two integers $ n $ and $ b $ (in decimal notation), your task is to calculate the number of trailing zero digits in the $ b $ -ary (in the base/radix of $ b $ ) representation of $ n\,! $ ([factorial](https://en.wikipedia.org/wiki/Factorial) of $ n $ ).输入输出格式
输入格式
The only line of the input contains two integers $ n $ and $ b $ ( $ 1 \le n \le 10^{18} $ , $ 2 \le b \le 10^{12} $ ).
输出格式
Print an only integer — the number of trailing zero digits in the $ b $ -ary representation of $ n! $
输入输出样例
输入样例 #1
6 9
输出样例 #1
1
输入样例 #2
38 11
输出样例 #2
3
输入样例 #3
5 2
输出样例 #3
3
输入样例 #4
5 10
输出样例 #4
1