i am getting crct for given test cases but while submitting wrong answer
I am getting crct for given test cases but while submitting wrong answer
#include
using namespace std;
int main(){
int t;
cin>>t;
while(tβ){
long long int n,m;
cin>>n>>m;
long long int x=m;
long long int sum=0;
while(n>=x){
sum=sum+(n/x);
x=x*m;
}
cout<<sum<<endl;
}
}
@coe17b014
Your logic is incorrect, Consider this testcase
1
6 4
output should be β2β since 6! = 720%4^2 = 720 %16 =0. But your code is giving β1β as output. Please go though hint videoβ¦
1 Like
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.