Page 9 of 16
Posted: Sat Apr 01, 2006 7:51 pm
by mf
The problem statement is unclear. ex. starting from input about "50.00" my output becomes very big. But this is not a big integer problem, right?
The problem statement is fine. It's always up to YOU to determine whether a problem needs bignums or not!
In this problem, the largest output is less than 2^48, so a 'long long' is sufficient.
The biggest problem with your code is that you may have rounding errors in this line:
On my computer your code doesn't even pass the sample input - it outputs 252 for input 2.00.
147 why WA????
Posted: Fri May 05, 2006 10:30 pm
by ranban282
code removed...
Posted: Sat May 06, 2006 3:59 am
by serur
What if
Code: Select all
printf("%6.2f%17llu\n",x,array[(long long)(x*20+0.5)][10]);
?
147 wa plz help...
Posted: Wed May 24, 2006 3:25 am
by yogeshgo05
hi guys i m getting wa for 147...
i just dont no whether the formatting of o/p is proper or not....
here's my code ...
147. Strange.
Posted: Sun Jun 04, 2006 7:34 pm
by shihabrc
While solving the problem i converted every coin and amount to multiple of 5c(by multiplying with 20). But i was getting WA. To my surprise when I changed the conversion code(as i found in one of the posts) from,
int money=(int) (amount*20) to
int money=(int) (amount*20+0.5) I got AC. can anyone explain why?
-Shihab
Posted: Mon Jun 05, 2006 2:02 am
by Darko
Because 'amount' is a floating point type and multiplying by powers of 10 (or even adding them) doesn't work quite well for numbers that are represented as powers of 2 (or something like that).
Instead of 0.5 any small number would do, 0.000001, for instance. Casting to int discards everything after the decimal point (and it might be something like .999999999)
You can read about it in misof's article:
http://www.topcoder.com/tc?module=Stati ... egersReals
Either avoid using floating points (if possible) or be paranoid while using them.
There's Goldberg's paper on the topic that I never bothered reading completely (maybe I should):
http://docs.sun.com/source/806-3568/ncg_goldberg.html
You can test it yourself with something like this (it's Java, but you get the idea):
Code: Select all
public class Test {
public static void main(String[] args) {
double a = 0.0;
for (int i = 0; i < 50; i++) {
System.out.println(i + " " + (20 * a));
a += 0.1;
}
}
}
147 why tle??????????????
Posted: Sat Jun 24, 2006 11:49 am
by SHAHADAT
This my code.Whats wrong is here?Why tle????
Code has been removed>>>>
why wa 147
Posted: Sat Jun 24, 2006 12:33 pm
by SHAHADAT
here is my code.Why wa????
Please can any one give critical input output?????????
code ha been removed.............
Posted: Sat Jun 24, 2006 8:11 pm
by emotional blind
you may devide each coins by 5
then
Code: Select all
int coin[11]={10000,5000,2000,1000,500,200,100,50,20,10,5};
becomes
Code: Select all
int coin[11]={2000,1000,400,200,100,40,20,10,4,2,1};
then you need less calculation.
Posted: Sun Jun 25, 2006 12:43 am
by the LA-Z-BOy
I dont know how you could NOT expect WA????
You just don't even match the sample cases given in the problem!!!!
v=12
Musn't it be
v=11
???
and more, if you take the input as
double, you can have precision errors.... it can be done with only integers to calculate the Cents. and if you are to use double then have some rounding stuff like
n=(taka*100+1e-5);
Bye.
Posted: Sun Jun 25, 2006 9:00 am
by SHAHADAT
Thanks a lot la-Z-BOy,
I have done a silly mistake.Atlast It is accepted
Posted: Sun Jun 25, 2006 9:12 am
by SHAHADAT
Thank's a lot emotional blind.
I have got it accepted......
147 ,WA
Posted: Sat Jul 08, 2006 2:48 am
by Carunty
I have got wrong answer for sereval times.I need some help.
I think it is a problem on the place of the output.
Thank you.
the code is remove because of accepted.
[/quote]
Posted: Sun Jul 16, 2006 12:25 pm
by Carunty
Any people can help me?
Posted: Sun Jul 16, 2006 6:38 pm
by Raiyan Kamal
Code: Select all
long long a[6000][11]; int b[]={1,2,4,10,20,40,100,200,400,1000,2000};
take a careful look at this line, you've made a little mistake here. I corrected it and got PE.