
147 - Dollars
Moderator: Board moderators
-
- New poster
- Posts: 39
- Joined: Tue Aug 07, 2012 10:40 pm
- Location: BUBT,Dhaka, Bangladesh
- Contact:
Re: 147 - Dollars
Input:
Output:
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
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/
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
147 .........wa
getting frequent wa 's..........any1 plz help


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 ;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 147 .........wa
Input:AC output:
Code: Select all
300.00
0.00
Code: Select all
300.00 181490736388615
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 5
- Joined: Tue Oct 08, 2013 2:32 pm
UVA 147 Wrong Answer
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.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 147 Wrong Answer
Check input and AC output for thousands of problems on uDebug!
Re: Solving Prob. 147
How come 0.5 becomes 0.05?
From UVA toolkit:
Input:
Output:
From UVA toolkit:
Input:
Code: Select all
299.5
0.5
0.05
300
Code: Select all
299.05 176638443641346
0.05 1
0.05 1
300.00 181490736388615
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: Solving Prob. 147
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!
Re: Solving Prob. 147
So 0.5 needs to be 0.50 in the input if it is to be 0.50 in the output?
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: Solving Prob. 147
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!
Re: 147 - Dollars
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:
Thanks for your reading!
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 ;-)
Last edited by s25g5d4 on Sun May 04, 2014 8:47 pm, edited 1 time in total.
Re: 147 - Dollars
%17I64d is not a valid format specifier for gcc/g++. You may use %17lld instead.s25g5d4 wrote:Please help me. Don't know why get WA.
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 wrote: Since the problem says each test case will be valid, I get the same output but invalid cases.
Does it matter?
Re: 147 - Dollars
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!
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!
-
- New poster
- Posts: 1
- Joined: Tue Jul 22, 2014 7:04 pm
Re: 147 - Dollars
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;
}