View difference between Paste ID: RQmMyu5d and XMnb8maf
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <cstdio>
3-
#include <vector>
3+
4
using namespace std;
5
6
typedef long long ll;
7
typedef unsigned int ui;
8
9-
ll k, n;
9+
ui k, n;
10
11-
ll minn(ll a, ll b) {
11+
ui minn(ui a, ui b) {
12
    if (a < b)
13
        return a;
14
    return b;
15
}
16
17
int main() {
18
    //freopen("input.txt", "r", stdin);
19
    //freopen("output.txt", "w", stdout);
20
    cin >> n >> k;
21
22-
    ll t = k, ch = 2, ans = 10000000000;
22+
    ui t = k, ch = 2, ans = 10000000000;
23
    while (t > 1) {
24-
        ll pk = 0, pn = 0, nn = ch;
24+
        ui pk = 0, pn = 0; ll nn = ch;
25-
        if (t % ch == 0) {
25+
	if (t % ch == 0) {
26
            while (t % ch == 0) {
27
                t /= ch;
28
                ++pk;
29
            }
30
            while (nn <= n) {
31
                pn += n / nn;
32
                nn *= ch;
33
            }
34
            ans = minn(pn / pk, ans);
35
        }
36
        ++ch;
37
    }
38
39
    cout << ans << endl;
40
41
    return 0;
42
}