Page 5 of 7

Posted: Sat Aug 05, 2006 5:18 pm
by Donotalo
got the bug. the function that counts the number of ways returns a long long where in the main function it was saved in an int. now i'm getting TLE.

Posted: Sat Aug 26, 2006 8:55 pm
by ldaniele
thank you,
i didn't understood why i always get WA
After reading ypour post i've solved!!!

Posted: Wed Aug 30, 2006 6:59 am
by Kallol
hey I am getting crazy with this problem. I have a got a lot of WA's but I dont know why ?
plz someone check my code..

Code: Select all

#include<stdio.h>
#include<memory.h>


#define MAX 40009

long long coin[MAX];
int a[11]={1,5,10,25,50};

void make()
{
	long i,j;
	for(i=0;i<MAX;i++)
	{
		coin[i]=1;
	}
	for(i=1;i<5;i++)
	{
		for(j=0;j<MAX-a[i];j++)
		{
			coin[j+a[i]]+=coin[j];
		}
	}
	//coin[0]=1;
	return;
}

int main(void)
{
	make();
	long x;

	while(scanf("%ld",&x)==1)
	{
		if(coin[x]==1)
		{
			printf("%There is only 1 way to produce %ld cents change.\n",x);
		}
		else
		{
			printf("There are %lld ways to produce %ld cents change.\n",coin[x],x);
		}
		
	}
	return 0;
}

Posted: Wed Aug 30, 2006 7:36 am
by Kallol
passed ur all cautions !
still WA .... now why it is ??

Code: Select all

cut after AC

Posted: Wed Aug 30, 2006 8:31 am
by Darko
It doesn't pass the sample input. No, it doesn't... look carefully :)

In general:
- check your output against the sample output using something like diff
- compile with -Wall (that would've helped in this case)
- in short - be paranoid

Posted: Wed Aug 30, 2006 10:51 am
by Kallol
Sorry Darko !
But I am totally confused ? Are u talking of any type of typing mistake in my output format? I checked it but couldnt find any.

Can u please give some I/O for which my program fails?

with thnx..

Posted: Wed Aug 30, 2006 5:39 pm
by Darko
You have a percentage sign in your output:

Code: Select all

printf("%There is o...
Have you tried the sample input? Or compiling with -Wall?

Posted: Wed Aug 30, 2006 6:50 pm
by Kallol
O GOSH !!!!!!!!!!

how silly it is and it wasted hours of mine.Now I got AC.
But why didnt I get anything wrong in VC?
Whatever.... thanx a lot Darko. You have been very helpful.

Posted: Wed Aug 30, 2006 6:52 pm
by Kallol
Hey !!
another thing .... i wanna know more about WALL. Whats this? I use Microsoft Visual C++ 6.0 Enterprise Edition . What is Wall? Whare can I get it? Is it more helpful? I work in Windows environment. Does Windows support Wall?

Posted: Wed Aug 30, 2006 8:22 pm
by Darko
Sorry, that's gcc's (another compiler) switch - stands for "Warnings all", I think.

I am not familiar with VC++, but look in help for compiler warnings and see if you can turn them on.

Posted: Thu Aug 31, 2006 8:15 am
by Kallol
OK.
Thank u for ur advices.
This type of helps and advices always inspire newbies like me .

Posted: Sun Dec 31, 2006 12:31 pm
by niangjun
originally I got WA because I output
" There is only 1 way to produce 1 cent change."
after which I changed my program to output
" There is only 1 way to produce 1 cents change." and got AC.....

Posted: Thu Mar 01, 2007 7:08 am
by joebin
long long array[30001];
int main{......}
just try it !!

Posted: Fri Mar 23, 2007 12:54 am
by Salehwar
How did you guys know the way to solve this problem?
I've seen few codes on the forum got accepted, but it doesn't make sense for me.

Maybe there is something I'm missing, anyone can help?

Thanks

Posted: Mon Jun 18, 2007 5:41 am
by google_goody

Code: Select all

#include<stdio.h> 
#include<stdlib.h> 

int money[5]={1,5,10,25,50}; 
long long count[30005]; 
int c,m,i; 
int in; 
int main() 
{ 
    for(i=1;i<30005;i++) 
       count[i]=0; 
    count[0]=1; 
    
     for(m=0;m<=4;m++) 
     { 
                  for(c=money[m];c<30005;c++) 
                  { 
                         count[c]+=count[c-money[m]]; 
                                            
                  } 
     } 
    
    while(scanf("%d", &in)==1) 
    { 
    
          if(count[in]!=1) 
          { 
              
             printf("There are %lld ways to produce ", count[in]); 
             printf("%d", in); 
             printf(" cents change.\n"); 
          } 
          else 
             printf("There is only 1 way to produce %d cents change.\n", in); 
     } 
      
     return 0; 
} 
          
could anyone help me with it.
this doesn't support 30000 and 29950