Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- ll n,b,sol,calc=1,i,aux;
- int main()
- {
- cin>>n>>b;
- for(aux=2;aux<=n;++aux){
- i=aux;
- while(i%b==0){i/=b,sol++;}
- calc=(calc*i)%b;
- if(calc==0)
- calc=1,sol++;
- }
- cout<<sol;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement