Page 4 of 7

Hi txandi!!!

Posted: Sun Mar 13, 2005 11:09 am
by dovier_antonio
Think this way:

const int monedas[ 5 ] = {1, 5, 10, 25, 50};
double array[ 30001 ] = { 1 };

for (int i = 0 ; i < 5 ; i++)
for (int j = 0 ; j <= 30000 - monedas[ i ] ; j++)
array[ monedas[ i ] + j ] += array[ j ];

I hope this help you...

Posted: Sun Mar 13, 2005 11:39 am
by ..
I give you 2 comments:

1. %0.0f is not a correct format, although it does what you want in this question. Check the document to see the meaning of that bolded zero %0.0f .

2. Don't use floating point if it is not necessary, so easy to fall in precision error.

Hi GURU !!!

Posted: Sun Mar 13, 2005 12:01 pm
by dovier_antonio
Ok... thanks

Posted: Sun Mar 13, 2005 12:06 pm
by ..
Yes, you can insist using your coding mathod, that's not my business.
But one day you will pay for using bad coding method in other problem.

Re: Hi!!! mb09

Posted: Sun Mar 13, 2005 9:01 pm
by ibrahim
dovier_antonio wrote:this is my code in this problem (357) :



I want that you will have accepted!!!

Dovier Antonio Ripoll Mendez
Hi dovier_antonio,
I think you are not doing the write things. Please don't give any accapted code in this board.
It will be better if you help him to solve his/her mistake. Ok? :D


Ibrahim

Posted: Mon Mar 14, 2005 2:02 am
by mb09
thx dovier_antonio and everyone
i've solved that problem myself and got ac =D
really thanks a lot

Hi !!!

Posted: Mon Mar 14, 2005 3:54 am
by dovier_antonio
I'm so sorry...

357 WA...... Why??

Posted: Wed Jul 20, 2005 6:07 am
by anisalamgir
anyone help me why i got WA for 357...
here my code

Code: Select all

[u][b]THIS  REMOVED BCOZ I GOT AC.......[/b][/u]
:oops:
thankx for all

Posted: Thu Jul 21, 2005 11:24 am
by mohiul alam prince
remove after helped.......
Because there was a AC source code in this post.

Thanks
MAP

hi

Posted: Thu Jul 21, 2005 4:35 pm
by J&Jewel
Anis ,
may be u find the solution....Ur program did not take multiple input...
this is a silly mistake...
u can solve the 147, 674 problem by this source concept...all r coin change problem.....GOOD LUCK

Posted: Sat Jul 23, 2005 7:01 am
by anisalamgir
Hi, Jewel&Prince...
First..A lot of thanks 4 ur tips.....
o my god!!!!!!!! I think it's my silly mistake....
yes.. finaly i got AC.

Agian thanks.. Jewel and Prince

357 Wrong Answer Dont know why ?????

Posted: Fri May 19, 2006 7:05 pm
by Ankur Handa
Can somebody where am i going wrong ?
I keep getting wrong answer ..

Code: Select all

#include<stdio.h>
#include<iostream>
#define MAX 30500
long long  array[30500]={0};
long long  coin[]={1,5,10,25,50};
int main(void)
{
        long long  cents=0;
        array[0]=1;
        array[1]=1;
        for(long long  i=0;i<5;i++)
        {
                for(long long  j=1;j<MAX;j++)
                {
                        if(coin[i]+j<MAX)
                        array[coin[i]+j]+=array[j];
                }
        }
        while(scanf("%lld",&cents)!=EOF)
        {
                if(array[cents]==1) printf("There is only 1 way to produce %lld cents change.\n",cents);
                else    printf("There are %lld ways to produce %lld cents change.\n",array[cents],cents);
        }
}

Thanks for the help ...
Can u give me some test cases ?
What should be the answer for cents = 0 ?

Posted: Fri May 19, 2006 9:55 pm
by Darko
Try

Code: Select all

5

if you want to know why you get WA on 357

Posted: Fri Jul 21, 2006 8:33 am
by plankton97330
Okay... This is such an easy problem, but took me 8 submissions to get it right... It is such a disaster when you know you have the right code but keep gettting WA for "no reason"...

so what you should check...

1. the input range is 0-30000 inclusive
2. result[30000]=543427145501, so use long long
3. result[0]=1

if above three hold for your code, then you must made a typo somewhere in your output...

Anyway, just hope my suffer can save others from their misery...

357 - Negative Answers!

Posted: Sat Aug 05, 2006 10:11 am
by Donotalo
i'm using long long everywhere but sometimes it gives me negative answers! why?

here is some sample input and output:

Code: Select all

0
There is only 1 way to produce 0 cents change.
1
There is only 1 way to produce 1 cents change.
4
There is only 1 way to produce 4 cents change.
5
There are 2 ways to produce 5 cents change.
10
There are 4 ways to produce 10 cents change.
11
There are 4 ways to produce 11 cents change.
17
There are 6 ways to produce 17 cents change.
99
There are 252 ways to produce 99 cents change.
300
There are 9590 ways to produce 300 cents change.
1000
There are 801451 ways to produce 1000 cents change.
2000
There are 11712101 ways to produce 2000 cents change.
3000
There are 57491951 ways to produce 3000 cents change.
4000
There are 178901001 ways to produce 4000 cents change.
5000
There are 432699251 ways to produce 5000 cents change.
6000
There are 891646701 ways to produce 6000 cents change.
7000
There are 1644503351 ways to produce 7000 cents change.
8000
There are -1498938095 ways to produce 8000 cents change.
9000
There are 172016955 ways to produce 9000 cents change.
10000
There are -1795806091 ways to produce 10000 cents change.
30000
There are -2033701091 ways to produce 30000 cents change.
what might be the problem?