147 - Dollars

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

Moderator: Board moderators

User avatar
@ce
Learning poster
Posts: 71
Joined: Mon May 28, 2012 8:46 am
Location: Ranchi, India

Re: 147 - Dollars

Post by @ce » Tue Jan 01, 2013 10:31 am

@brianfry713....precision error....thanks...i got AC :)
-@ce

alimbubt
New poster
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh
Contact:

Re: 147 - Dollars

Post by alimbubt » Wed Mar 27, 2013 2:51 pm

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
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/

udoy
New poster
Posts: 7
Joined: Sat Sep 28, 2013 11:27 am

147 .........wa

Post by udoy » Sat Sep 28, 2013 11:38 am

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 ;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Post by brianfry713 » Tue Oct 01, 2013 1:06 am

Input:

Code: Select all

300.00
0.00
AC output:

Code: Select all

300.00  181490736388615
Check input and AC output for thousands of problems on uDebug!

udoy
New poster
Posts: 7
Joined: Sat Sep 28, 2013 11:27 am

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

Post by udoy » Thu Oct 03, 2013 10:23 pm

tnx bro...... :D

nikunjbanka
New poster
Posts: 5
Joined: Tue Oct 08, 2013 2:32 pm

UVA 147 Wrong Answer

Post by nikunjbanka » Wed Oct 16, 2013 12:10 pm

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.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 147 Wrong Answer

Post by brianfry713 » Wed Oct 16, 2013 8:29 pm

Check input and AC output for thousands of problems on uDebug!

jddantes
Learning poster
Posts: 73
Joined: Sat Mar 08, 2014 8:55 am

Re: Solving Prob. 147

Post by jddantes » Tue Mar 11, 2014 7:17 pm

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

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Solving Prob. 147

Post by brianfry713 » Tue Mar 11, 2014 10:00 pm

Each line in the judge's input has exactly 2 digits after the decimal point.
Check input and AC output for thousands of problems on uDebug!

jddantes
Learning poster
Posts: 73
Joined: Sat Mar 08, 2014 8:55 am

Re: Solving Prob. 147

Post by jddantes » Wed Mar 12, 2014 2:36 pm

So 0.5 needs to be 0.50 in the input if it is to be 0.50 in the output?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Solving Prob. 147

Post by brianfry713 » Wed Mar 12, 2014 8:37 pm

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.
Check input and AC output for thousands of problems on uDebug!

s25g5d4
New poster
Posts: 2
Joined: Sun May 04, 2014 3:34 pm

Re: 147 - Dollars

Post by s25g5d4 » Sun May 04, 2014 3:48 pm

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!
Last edited by s25g5d4 on Sun May 04, 2014 8:47 pm, edited 1 time in total.

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 147 - Dollars

Post by lbv » Sun May 04, 2014 7:52 pm

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?

s25g5d4
New poster
Posts: 2
Joined: Sun May 04, 2014 3:34 pm

Re: 147 - Dollars

Post by s25g5d4 » Sun May 04, 2014 8:47 pm

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!

riccardomereu5
New poster
Posts: 1
Joined: Tue Jul 22, 2014 7:04 pm

Re: 147 - Dollars

Post by riccardomereu5 » Fri Aug 15, 2014 8:35 pm

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;
}

Post Reply

Return to “Volume 1 (100-199)”