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

tobat
New poster
Posts: 2
Joined: Mon Apr 27, 2009 3:17 pm

Re: why wa 147

Post by tobat » Mon Apr 27, 2009 3:32 pm

It's accepted!
Last edited by tobat on Mon Apr 27, 2009 4:57 pm, edited 1 time in total.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: why wa 147

Post by mf » Mon Apr 27, 2009 3:45 pm

Why wa
Can you read???

You made exactly the same mistake as almost everyone who posted here about their WA.

In short, to illustrate what it is, consider the following C/C++ boolean expressions:

Code: Select all

(int)(0.29 * 100) == 28
(int)(0.57 * 100) == 56
(int)(0.58 * 100) == 57
(int)(1.13 * 100) == 112
(int)(1.14 * 100) == 113
(int)(1.15 * 100) == 114
...
Here's the bummer: they all evaluate to true. You didn't see that coming, did you?

I suggest you read this article and this paper if you're curious why.

tobat
New poster
Posts: 2
Joined: Mon Apr 27, 2009 3:17 pm

Re: why wa 147

Post by tobat » Mon Apr 27, 2009 4:56 pm

Thank you very much!
I'm so careless!
now I get AC,I will be careful next.
Thanks again.

User avatar
fushar
New poster
Posts: 26
Joined: Fri Apr 03, 2009 12:09 pm
Location: Indonesia
Contact:

Re: why wa 147

Post by fushar » Tue Apr 28, 2009 12:20 am

I didn't use any floating point in this problem. To read the input, just type:

Code: Select all

scanf("%d.%d", &note, &coin);
It's so simple right?

Taman
New poster
Posts: 32
Joined: Sun Oct 11, 2009 8:59 pm
Location: Southeast University

Re: 147 ,WA

Post by Taman » Fri Dec 25, 2009 2:58 pm

Thanks to Jan vai for his sample cases :)
Last edited by Taman on Mon Nov 29, 2010 9:54 am, edited 1 time in total.

Taman
New poster
Posts: 32
Joined: Sun Oct 11, 2009 8:59 pm
Location: Southeast University

Re: 147 __int64 can't hold big results.Please help

Post by Taman » Fri Dec 25, 2009 3:01 pm

@Newton: Hope that I am too late. You have solved the problem btt.:)
check these inputs :
0.11
0.12
0.01


And the title of this thread is wrong:)
long long is enough for this problem. :) @ least I got acc using %lld ;)

seraph
New poster
Posts: 9
Joined: Tue Dec 15, 2009 4:18 pm

Re: 147 __int64 can't hold big results.Please help

Post by seraph » Sat Jan 09, 2010 5:43 am

i know why your code is WA :
your code

Code: Select all

printf("%6.2f%17llu\n", input, ways[ans]);
should :

Code: Select all

printf("%6.2f%17llu\n", input[b]+eps[/b], ways[ans]);
only thats, n you will AC :D :D :D

yan yan
New poster
Posts: 13
Joined: Thu May 13, 2010 4:16 pm
Location: Viet Nam
Contact:

Re: 147 ,WA

Post by yan yan » Fri Jun 11, 2010 3:34 am

everybody please help me :oops: , i don't understand why it's wrong..... :(

Code: Select all

removed after AC

@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

147 how to calculate coin change?

Post by @mjad » Wed Oct 20, 2010 5:53 am

please any body help me.
give me an example of coin change made up.

md_yusuf
New poster
Posts: 9
Joined: Fri Jun 25, 2010 11:09 pm

Re: 147 __int64 can't hold big results.Please help

Post by md_yusuf » Fri Jan 14, 2011 9:48 pm

plz help me.. why wa..

Code: Select all

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

unsigned long long a[50000];

int main()
{
	unsigned long long i,j;
	int coin[]={5,10,20,50,100,200,500,1000,2000,5000,10000};
	a[0]=1;
	for(i=0;i<11;i++)
	{
		for(j=0;j<=30000;j++)
			a[j+coin[i]]+=a[j];
	}
	double n;
	while(1)
	{
		scanf("%lf",&n);
		int m;
		m=n*100;
		if(m==0)
			break;
		printf("%6.2lf%17llu\n",n,a[m]);
	}
}

i have check answer in uvatoolkit i think i have problem in output plz help me.
plz help im getting frustrated ....

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

Re: 147 __int64 can't hold big results.Please help

Post by sazzadcsedu » Sat Jan 15, 2011 4:50 pm

Rather than doing-
m= (n* 100), do this:
m = (int) (n * 100 + 0.5) to avoid floating point error.
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com

shamsacm
New poster
Posts: 6
Joined: Sat May 07, 2011 12:45 pm

Re: 147 __int64 can't hold big results.Please help

Post by shamsacm » Wed Jun 29, 2011 2:17 pm

For floating point error

Input two integer number
Example

Code: Select all

scanf("%d.%d",&d,&c);
amount = d*100 + c;

shamsacm
New poster
Posts: 6
Joined: Sat May 07, 2011 12:45 pm

Re: 147 __int64 can't hold big results.Please help

Post by shamsacm » Wed Jun 29, 2011 2:22 pm

Pls replace your code

Use integer not floating point

Code: Select all

 //scanf("%lf",&n);
     scanf("%d.%d",&d,&c);
      int m;
      //m=n*100;
      m = d*100+c;
      if(m==0)
         break;
      //printf("%6.2lf%17llu\n",n,a[m]);
      printf("%3d.%.2d%17llu\n",d,c,a[m]);

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

147 - Dollars

Post by @ce » Mon Dec 31, 2012 8:51 am

Getting WA....plzz help...any testcase

Code: Select all

AC
Last edited by @ce on Tue Jan 01, 2013 10:31 am, edited 1 time in total.
-@ce

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

Re: 147 - Dollars

Post by brianfry713 » Tue Jan 01, 2013 3:04 am

Input:

Code: Select all

0.30
0.00
AC output:

Code: Select all

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

Post Reply

Return to “Volume 1 (100-199)”