Thanks In advance.
Code: Select all
#include <stdio.h>
int main()
{
int n,m,ns,lc,temp,t,count;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
ns = n/m;
lc = n%m;
temp = ns + lc;
count = 1;
while (temp>=m)
{
ns = temp/m;
lc = temp%m;
temp = ns + lc;
count++;
}
if (lc != 0)
printf("cannot do this");
else
printf("%d",count);
if(t)
printf("\n");
}
return 0;
}