Advertisement
Alhiris

NICE TRY2

Feb 10th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. ll n,b,sol,calc=1,i,aux;
  6.  
  7.  
  8. int main()
  9. {
  10.    
  11.     cin>>n>>b;
  12.     for(aux=2;aux<=n;++aux){
  13.         i=aux;
  14.         while(i%b==0){i/=b,sol++;}
  15.         calc=(calc*i)%b;
  16.         if(calc==0)
  17.             calc=1,sol++;
  18.     }
  19.     cout<<sol;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement