#P3927. SAC E#1 - 一道中档题 Factorial

    ID: 2867 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>洛谷原创O2优化素数判断,质数,筛法进制概率论,统计洛谷月赛

SAC E#1 - 一道中档题 Factorial

Description

SOL 君 likes factorials, while SOL 菌 enjoys studying number bases.

One day, SOL 君 showed off to SOL 菌 by casually computing the factorial of nn.

SOL 菌 was unconvinced and immediately wanted to compute the number of trailing zeros of this number in base kk.

However, SOL 菌 is not skilled enough, so he asks you for help.

Input Format

Each input contains a single line with two integers n,kn,k.

Output Format

Output a single integer: the number of trailing zeros of n!n! in base kk.

10 40
2

Hint

  • For 20%20\% of the testdata, n1000000,k=10n \le 1000000, k = 10.
  • For another 20%20\% of the testdata, n20k36n \le 20, k \le 36.
  • For 100%100\% of the testdata, n1012k1012n \le 10^{12},k \le 10^{12}.

Update

  1. Each test point contains only one test case.
  2. kk will not be 11.
  3. Now the std does not overflow long long.
  4. If there is any problem with the testdata, contact icy (it is recommended not to code to the data).

Translated by ChatGPT 5