#include <stdio.h>
int main() {
int t,s,n,m;
scanf("%d",&s);
while(s--)
{
scanf("%d %d",&n,&m);
t=0;
for(;n>0;)
{
n=n/m;
t+=n;
}
printf("%d\n",t);
}
}
转载于:https://www.cnblogs.com/Tristan-Adams/p/9066096.html
#include <stdio.h>
int main() {
int t,s,n,m;
scanf("%d",&s);
while(s--)
{
scanf("%d %d",&n,&m);
t=0;
for(;n>0;)
{
n=n/m;
t+=n;
}
printf("%d\n",t);
}
}
转载于:https://www.cnblogs.com/Tristan-Adams/p/9066096.html