Page 1 of 1

11313 - Gourmet Games

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

Re: 11313 - GOURMET GAMES

Posted: Sun Aug 24, 2008 8:37 am
by Samiul
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.

Re: 11313 - GOURMET GAMES

Posted: Tue Oct 07, 2008 4:08 pm
by lnr
To nahid
Check this.

Input:

Code: Select all

1
8 2
Output:

Code: Select all

7

Re: 11313 - GOURMET GAMES

Posted: Mon Nov 08, 2010 11:52 pm
by Shafaet_du
Nice adhoc :).
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

Re: 11313 - GOURMET GAMES

Posted: Mon Oct 28, 2013 4:02 pm
by mahade hasan
cuttttttttttttt

Re: 11313 - GOURMET GAMES

Posted: Thu Jul 10, 2014 1:39 pm
by uDebug
Shafaet_du,
Thanks for the test cases.