Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using llong = long long;
  4.  
  5. int main() {
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(0);
  8. cout.tie(0);
  9.  
  10. llong n, k;
  11. cin >> n >> k;
  12.  
  13. llong zeros = LLONG_MAX;
  14.  
  15. for (auto i = 2; i <= k; i++)
  16. {
  17. if (!(k % i))
  18. {
  19. llong c = 0;
  20. while (!(k % i))
  21. {
  22. c++;
  23. k /= i;
  24. }
  25. llong c_2 = 0;
  26. llong d = n;
  27. while (d / i > 0)
  28. {
  29. c_2 += d / i;
  30. d /= i;
  31. }
  32. zeros = min(zeros, c_2 / c);
  33. }
  34. }
  35.  
  36. cout << zeros;
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement