## 11313 - Gourmet Games

Moderator: Board moderators

nahid
New poster
Posts: 18
Joined: Wed Oct 04, 2006 8:59 pm
Contact:

### 11313 - Gourmet Games

As usual i'm having WA with this easy problem. here is my code. would u pls check it .

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;
}
``````

Samiul
New poster
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

### Re: 11313 - GOURMET GAMES

Each time you are updating the variable temp, you are increasing count by 1 but it would be increased by the number of shows held, which is ns.

lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm

### Re: 11313 - GOURMET GAMES

To nahid
Check this.

Input:

Code: Select all

``````1
8 2
``````
Output:

Code: Select all

``````7
``````

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Contact:

### Re: 11313 - GOURMET GAMES

sample:

Code: Select all

``````7
10 4
11 4
19 2
100 10
999 32
345 234
10000 12``````
output:

Code: Select all

``````3
cannot do this
18
11
cannot do this
cannot do this
909
``````

Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm

### Re: 11313 - GOURMET GAMES

cuttttttttttttt
we r surrounded by happiness
need eyes to feel it!

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 11313 - GOURMET GAMES

Shafaet_du,
Thanks for the test cases.
Check input and AC output for over 7,500 problems on uDebug!