Page 12 of 16

Posted: Tue Aug 14, 2007 10:20 pm
by Jan
That's why its better to print doubles like

Code: Select all

printf("%0.lf",x+eps); 
Hope it helps.

TLE...Plz Help.

Posted: Fri Aug 17, 2007 10:45 pm
by sunny_boy_in
My code gives TLE. Please help

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>

int main()
{
while(1) {
int dec=0,frac=0;
scanf("%d.%d",&dec,&frac);
long value=(dec*100+frac);
if(value==0) break;
double val;
unsigned long long ways[7001][11];
memset(ways,0,sizeof(ways));

if(value%5!=0) {
ways[value][10]=0;
val=value/100.00;
}
else {
value/=5;
int coins[11]={1,2,4,10,20,40,100,200,400,1000,2000};
for(int i=0;i<11;i++) ways[0]=1;
for(int i=1;i<=value;i++) {
for(int j=0;j<11;j++) {

unsigned long long type1=(j==0?0:ways[j-1]);
unsigned long long type2=(i>=coins[j]?ways[i-coins[j]][j]:0);
ways[j]=type1+type2;

}

}

val=value/20.0;
}
printf("%6.2lf%17llu\n",val,ways[value][10]);
}
return 0;
}

Posted: Sun Sep 23, 2007 8:10 pm
by rhsumon
Why Compile error???
I can't imagin about this.......

Code: Select all

Removed after AC
plz notify someone about this.......

Posted: Sun Sep 23, 2007 8:16 pm
by Jan
I think 'void main' is the problem. You must use

Code: Select all

int main()
{
    // bla bla bla
    return 0;
}
Hope it helps.

Posted: Sun Sep 23, 2007 8:29 pm
by rhsumon
I've forgot about this but now also it gives me PE

What can i do plz .............

Posted: Mon Sep 24, 2007 1:16 pm
by Jan
Edit : The correct format is given below.

Posted: Mon Sep 24, 2007 6:25 pm
by rhsumon
But that line first i submitted
It was a presentation Error......
After that i gave this one........

Posted: Mon Sep 24, 2007 7:40 pm
by Jan
I haven't understood you fully. Why did you use %10lld?

Posted: Mon Sep 24, 2007 9:09 pm
by rhsumon
I mean first field width is 6 so to set last field width to 17 it's need to add more 10 width so that i printed that.......

At first i printed 6 and 17 but that was also PE

So what can i do?

Give me some trics.......

Posted: Tue Sep 25, 2007 10:59 am
by Jan
Try this one (Sorry, I was wrong :-? )

Code: Select all

printf("%6.2lf%17lld\n",n+1e-7,nway[amnt]);
Hope it helps.

Posted: Tue Sep 25, 2007 4:58 pm
by rhsumon
I cannot understand why this was a PE ......... It should have WA .......
Am i wrong?? Plz give some info about it.

Posted: Tue Sep 25, 2007 5:11 pm
by Jan
Your previous code was correct except the formatting. The 1e-7 was given for safety, nothing else. Check carefully, you used %17lld but there was a space behind it. :) So, it was PE.

Posted: Thu Nov 15, 2007 2:42 pm
by WingletE

Code: Select all

(int)(n * 100.0 + 1e-6)
Would it be the reason of wrong answer?
Or there might be other errors in my code?

Please give me some more tricky test cases.
Thanks!

Posted: Thu Nov 15, 2007 6:49 pm
by Jan
I can't think of any tricky case. You can post your code.

Posted: Sat Nov 17, 2007 10:26 am
by WingletE
Here's my code.
I use the same method as problem 357.
I really don't know where could be wrong...

Code: Select all

Code deleted!!!
Thanks for checking it for me!