学到好多。。大佬们tql
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
#define N 200010
#define LL long long
using namespace std;
const LL inf = 1e18;
int main()
{
LL n, b;
scanf("%lld%lld", &n, &b);
LL ans = inf;
LL temp, mul;
for (LL i = 2; i <= b; i++)
{
if (i * i > b)i = b;
if (b % i == 0)
{
LL t = 0;
while (b % i == 0)
{
b /= i;
t++;
}
mul = 1, temp = 0;
while (n / i >= mul)
{
mul *= i;
temp += n / mul;
}
ans = min(ans, temp / t);
}
}
printf("%lld\n", ans);
return 0;
}