Page 3 of 4
Posted: Thu Nov 11, 2004 12:01 am
by Sanny
Hi,
There can be some problem in ur printf().
printf("2^-%ld = %1.3fe-%d\n",n,a[n].x,a[n].y);
The actual data types for a[n].x and a[n].y were long double and long int respectively. But u used %f and %d in the printf().
Posted: Thu Nov 11, 2004 2:33 am
by Heartattack!
I've tried it with %Lf,, %lf, using strings, %f.....

I think the problem is with rounding. I tried printf("%1.3Lf",...) which got WA. I added 0.00001 to the float. That too got WA. I wrote a function to round to 3 decimal digits which rounds like we do(1.00044445==1.001), and you guessed it, that got WA. Could you send me some sample output? What'll the following produce?
Code: Select all
11
12
13
23
24
25
7
6
47
48
49
1000000
Better yet, if you got AC, could you send the code by mail? I'll only check the answers to see the required output format. I'm not one for stealing code

.Thanks in advance.
Posted: Fri Nov 12, 2004 1:36 am
by Sanny
My AC program gives the following output ->
Code: Select all
2^-11 = 4.883e-4
2^-12 = 2.441e-4
2^-13 = 1.221e-4
2^-23 = 1.192e-7
2^-24 = 5.960e-8
2^-25 = 2.980e-8
2^-7 = 7.813e-3
2^-6 = 1.563e-2
2^-47 = 7.105e-15
2^-48 = 3.553e-15
2^-49 = 1.776e-15
2^-1000000 = 1.010e-301030
Hope it helps.
Posted: Sat Nov 13, 2004 7:54 am
by Heartattack!
Thanks.
I changed all the ints to longs, all %ds to %lds and the %1.3lf to %1.3LF. For some reason that got AC!!!!
Proper rounding caused WA.

p474 get WA need sample input
Posted: Thu Apr 28, 2005 2:52 am
by sunnycare
i have solved problem 545 , but get WA when i submit p474
..
my algorithm is simple....
Code: Select all
cin>>n;
cout<<"2^"<<n<<" = ";
tmp=log10((double)2)*(n);
b=floor(tmp);
a=pow((double)10,tmp-b);
cout<<a<<'e'<<b<<endl;
my code here ,thanks to help me test it with your AC prog thanks
Code: Select all
//474 Heads / Tails Probability
///////////////////////////////
//same as 545
///////////////////////////////
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc,char *argv[])
{
long n;
double a,tmp;
long b;
cout.setf(ios::fixed,ios::floatfield);
cout.precision(3);
while(cin>>n)
{
n=-n;
cout<<"2^"<<n<<" = ";
tmp=log10((double)2)*(n);
b=floor(tmp);
a=pow((double)10,tmp-b);
cout<<a<<'e'<<b<<endl;
}
}
Posted: Fri Apr 29, 2005 11:09 pm
by Antonio Ocampo
Hi sunnycare
Have you noticed this 1<=n<=1000000 ?
So "n" doesn`t fit in an int. It should be a long long.
Hope it helps

Posted: Mon May 02, 2005 4:27 am
by sunnycare
although i have changed it to long long , OJ still give me a WA...
by the way,why to use long long ??
i think long is enough..
need help
Posted: Tue May 03, 2005 2:01 am
by Antonio Ocampo
Hi sunnycare
You're right! int is enough
But the set of possible inputs is quite limited. You can generate them all, send me the input file and I will send you my output for it
Keep posting
need 474 sample input and output
Posted: Fri Jun 24, 2005 5:33 am
by sunnycare
who can send me your sample in/out sample
or your exe file.
my mail is
thanks...
Posted: Sun Aug 13, 2006 10:03 pm
by thurbo
Hi,
I also got a WA first, read this post changed my solution and got accepted.
Now the funny part is that I checked all possibilities and got the same result, except for n = 6.
My solution gave first 2^-6 = 1.563e-2 and got a WA.
Now it returns 2^-6 = 1.562e-2 and it gets accepted. In my opinion this is a wrong answer (1.5625 should round up to 1.563).
Even funnier is that my original solution gets accepted for 545 while the alternative solution gets WA...
Greetings,
Jeroen
Posted: Fri Sep 01, 2006 6:30 am
by wktang
Now the funny part is that I checked all possibilities and got the same result, except for n = 6.
My solution gave first 2^-6 = 1.563e-2 and got a WA.
Now it returns 2^-6 = 1.562e-2 and it gets accepted. In my opinion this is a wrong answer (1.5625 should round up to 1.563).
This is crazy! I've got 10 WA's before I read your post.. and I added the exception case for (n = 6, which i strongly believe the correct answer to be 1.563e-2) and got AC!!! Thanks to your post again...
So isn't anyone going to correct the error? This is really frustrating... solving problems like this!

Posted: Sun May 13, 2007 12:40 am
by LithiumDex
I did the exact same thing, and then got AC -- If not directly a bug in the judges output, it must have been a bug or "nuance" in the library used with the code to produce that output.
474, Need help WA
Posted: Fri May 25, 2007 5:19 pm
by Manu_bk
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout.setf(ios::fixed);
cout.precision(3);
long n;
double a,tmp;
long b;
while(cin>>n) {
n=-n;
cout<<"2^"<<n<<" = ";
tmp=log10((double)2)*(n);
b=long(floor(tmp));
a=pow((double)10,tmp-b);
cout<<a<<'e'<<b<<endl;
}
}
Posted: Fri May 25, 2007 5:33 pm
by little joey
Read the forum description: don't open a thread for a problem if one exists.
Re: 474 problem
Posted: Mon Mar 28, 2011 3:38 pm
by shopno
You should look at the input of the 6.
The judge data does not consider the round about.
2^-6 = 1.562e-2 (The judge)
2^-6 = 1.563e-2 (Mathematical result)
Be careful. This is nothing but wasting time solving this problem/
