No, it’s not about trailing zeros. Default precision for cout <<
is 6 significant digits, so it could be wrong on borderline cases (I think). Also the grader might not accept scientific notation which by default is used for large floating point numbers.
Umm, what is “ABC”?
Atcoder Beginner Contest (ABC)
auto F() {
ll n;
cin>>n;
long double as=0,bs =0;
while(n--) {
cin>>g>>a>>b;
as += b * ( g/ (a+b));
bs += a * ( g/(a+b));
}
cout<<as<<" "<<bs;
return "";
}
this is my code everything is same except the precision part it got WA. Can someone explain why it got WA.
https://www.codechef.com/viewsolution/34819585
If u print long double values always print at least 6 digits after decimal like this -
cout<<fixed<<setprecision(6)<<value;
You have used map in your last solution which increases the complexity, also don’t be offended but that’s lot of code. I mean the get_hash function was never required. Here is my full solution if you want to compare.
yes, but in question they didn’t mention to print upto six decimal places it was mentioned that relative error must not exceed 10^-6. So where does it go wrong
When i set precision to 10 now it says correct answer.Thank you.
please see all my submissions that is I applied binary search too. using adjacentcy lists
I used map only after my submission based on binary search was TLED.
I am sorry I do not have a formal proof. It was LTIME so used proof by AC.
Ohh boy!
I used cout<<setprecision(6).
instead of cout<<fixed<<setprecision(6)
And due to this an array of WA.
You have a lot of submissions. Better comment the link of the one you want me to see
But why to use setprecision it was never mentioned to print upto six decimal places
It doesn’t occur to you that if you don’t print at least 6 significant digits the relative error will be greater than 1e-6?
Leave it , I came to know that only a silly trick is going to work this problem , other than that all submissions are waste. and thus it concludes that without implementing by thAT SINGLE WAY I couldnt get AC. Thanks for your time
IF You want you can check this submission.
https://www.codechef.com/viewsolution/34813993
, Sorry if you felt bad by mu rudeness , I got angry with the platform just nothing else.
Sorry ,I don’t do much competitive programming how the solution is evaluated they consider my answer as string and check the first six decimal places or do they take it as real number
Sorry if you felt bad by mu rudeness
Not at all
I got angry with the platform just nothing else
Been there, done that innumerable times.
Chill…
Ya it was my mistake too! as cutting lemons with swords seems true for codechef and I must have remembered it.
I did think that but i never tried to submit it. Sad life T_T.
It’s either that the default rounding to 6 significant digits introduced too much error or that the grader doesn’t accept scientific notation which by default is used for large floating point numbers.