11313 - GOURMET GAMES

All about problems in Volume CXIII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

11313 - GOURMET GAMES

Postby nahid » 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.

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;
}
User avatar
nahid
New poster
 
Posts: 18
Joined: Wed Oct 04, 2006 8:59 pm
Location: DHAKA,BANGLADESH

Re: 11313 - GOURMET GAMES

Postby Samiul » Sun Aug 24, 2008 8:37 am

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.
Samiul
New poster
 
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

Re: 11313 - GOURMET GAMES

Postby lnr » Tue Oct 07, 2008 4:08 pm

To nahid
Check this.

Input:
Code: Select all
1
8 2

Output:
Code: Select all
7
User avatar
lnr
Experienced poster
 
Posts: 134
Joined: Sat Jun 30, 2007 2:52 pm
Location: (DU,CSE)Dhaka,Bangladesh

Re: 11313 - GOURMET GAMES

Postby Shafaet_du » Mon Nov 08, 2010 11:52 pm

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
Shafaet_du
Experienced poster
 
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh


Return to Volume CXIII

Who is online

Users browsing this forum: No registered users and 1 guest

cron