Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int fonction(int a, int b)
- {
- int total = 0;
- int i = 1;
- while (pow(a, i) < b)
- {
- total += b / pow(a, i);
- i++;
- }
- return total;
- }
- int main()
- {
- int a;
- int b;
- cin >> a >> b; cin.ignore();
- int total = 0;
- vector<int> v;
- int c = a;
- int i = 2;
- while (c != 1)
- {
- if (c % i == 0)
- {
- c /= i;
- v.push_back(i);
- }
- else
- i++;
- }
- i = 0;
- int min = 100000;
- while (i < v.size())
- {
- int h = fonction(v[i], b) / count(v.begin(), v.end(), v[i]);
- if (h < max)
- max = h;
- i++;
- }
- cout << max << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement