Page 15 of 16

Re: 147 - Dollars

Posted: Tue Jan 01, 2013 10:31 am
by @ce
@brianfry713....precision error....thanks...i got AC :)

Re: 147 - Dollars

Posted: Wed Mar 27, 2013 2:51 pm
by alimbubt
Input:

Code: Select all

0.30
12.35
2.25
3.55
9.90
199.90
288.45
278.42
285.65
300.00
122.40
148.90
43.68
123.90
0.00
Output:

Code: Select all

  0.30                6
 12.35           267166
  2.25              388
  3.55             1714
  9.90            99998
199.90    7374160359543
288.45  131885563682391
278.42                0
285.65  121901430488365
300.00  181490736388615
122.40     196443681978
148.90     810222739797
 43.68                0
123.90     214269035082

147 .........wa

Posted: Sat Sep 28, 2013 11:38 am
by udoy
getting frequent wa 's..........any1 plz help

:oops: :oops:

Code: Select all

#include<cstdio>
#include<iostream>
#include <cstring>
#define max 30000
using namespace std;
long long int  c=30001,len,dp[12][max],coin[]= {5,10,20,50,100,
200,500,1000,2000,5000,10000};
long long int func(long long int i,long long int amount)
{
    if(i>=len)
    {
        if(amount==0)
            return 1;
        else return 0;
    }

    if(dp[i][amount]!=-1)
        return dp[i][amount];
    long long int pro1=0;
    if(amount-coin[i]>=0)
        pro1=func(i,amount-coin[i]);

    long long int pro2=func(i+1,amount);
    return dp[i][amount]=pro1+pro2;
}

int main()

{
    long long int  a,b,d;

    len=sizeof(coin)/8;
    memset(dp,-1,sizeof(dp));
    func(0,30001);
    for (; (scanf("%lld.%lld",&c,&d)) ==2; )
    {
        if(c==0 && d==0)
            return 0;
        a=c*100+d;

        printf("%3lld.%.2lld%17lld\n",c,d,func(0,a));

    }
    return 0 ;
}

Re: 147 .........wa

Posted: Tue Oct 01, 2013 1:06 am
by brianfry713
Input:

Code: Select all

300.00
0.00
AC output:

Code: Select all

300.00  181490736388615

Re: 147 .........wa

Posted: Thu Oct 03, 2013 10:23 pm
by udoy
tnx bro...... :D

UVA 147 Wrong Answer

Posted: Wed Oct 16, 2013 12:10 pm
by nikunjbanka
I am always getting WA on UVA 147 Dollars. Please provide some test cases or suggest why I am getting WA. The main code that I use is same as that for UVA 674 Coin Change for which I have AC.

Re: UVA 147 Wrong Answer

Posted: Wed Oct 16, 2013 8:29 pm
by brianfry713

Re: Solving Prob. 147

Posted: Tue Mar 11, 2014 7:17 pm
by jddantes
How come 0.5 becomes 0.05?
From UVA toolkit:
Input:

Code: Select all

299.5
0.5
0.05
300
Output:

Code: Select all

299.05  176638443641346
  0.05                1
  0.05                1
300.00  181490736388615

Re: Solving Prob. 147

Posted: Tue Mar 11, 2014 10:00 pm
by brianfry713
Each line in the judge's input has exactly 2 digits after the decimal point.

Re: Solving Prob. 147

Posted: Wed Mar 12, 2014 2:36 pm
by jddantes
So 0.5 needs to be 0.50 in the input if it is to be 0.50 in the output?

Re: Solving Prob. 147

Posted: Wed Mar 12, 2014 8:37 pm
by brianfry713
It looks like if you want the correct output from uvatoolkit you need to give it input that has exactly 2 digits after the decimal point.

Re: 147 - Dollars

Posted: Sun May 04, 2014 3:48 pm
by s25g5d4
Please help me. Don't know why get WA.
I've tested the above test cases.
Since the problem says each test case will be valid, I get the same output but invalid cases.
Does it matter?

My code:

Code: Select all

remove for AC ;-)
Thanks for your reading!

Re: 147 - Dollars

Posted: Sun May 04, 2014 7:52 pm
by lbv
s25g5d4 wrote:Please help me. Don't know why get WA.
%17I64d is not a valid format specifier for gcc/g++. You may use %17lld instead.

s25g5d4 wrote: Since the problem says each test case will be valid, I get the same output but invalid cases.
Does it matter?
I'm afraid I don't understand what you're trying to say here. Are you saying you tried your program against invalid cases? Or that you're confident that the judge data contains invalid cases? Or something else?

Re: 147 - Dollars

Posted: Sun May 04, 2014 8:47 pm
by s25g5d4
I apologize for my poor English.
What I mean is some of the test cases provided by alimbubt were invalid, like "278.42".
With my code it won't output 0, it shows 99254706249644.

Thanks for your help, I got AC!

Re: 147 - Dollars

Posted: Fri Aug 15, 2014 8:35 pm
by riccardomereu5
Why do I get WA?

Code: Select all

 
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ofstream out("output.txt");
long long table[30010];
int money[11]={5, 10, 20, 50, 100, 200, 500, 1000,  2000, 5000, 10000};
int main(int argc, char** argv) {
    memset(table, 0, sizeof table);
    table[0]=1;
    for(int i=0; i<11; i++){
        for(int j=money[i]; j<=30010; j++){
            table[j]+=table[j-money[i]];
            //out<<j<<endl;
        }
    }
    float n;
    cin>>n;
    while(n!=0.00){
        cout.width(6);
        cout.precision(2);
        cout << fixed << right << n;
        cout.width(17);
        n*=100;
        cout<<right<<table[(int)n]<<endl;
        cin>>n;
    }
     
    return 0;
}