11313 - Gourmet Games
Posted: Thu Aug 21, 2008 8:33 pm
As usual i'm having WA with this easy problem. here is my code. would u pls check it .
Thanks In advance.
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;
}