← Back to topics
Topic

z-capacitors

n
n.vilcins
Could someone explain how the precision is graded. The problem statement asks us to give the nomber with precision to 10 decimal places. As I was solving this problem, I tried many different methods and got whether wrong results or solutions that gave the number with precision to 9 decimal places. I came to conclusion that because of many calculations it always lost the 10th digit (because manually setting some value with 10 digit precisios it outputs that number correctly). When, after solving other problems, I had 3 minutes left, I decided to try my luck and submitted the straight forward solution which produced not-percise enough values. For my surprise it was accepted and then passed all test cases. Maybe the actual precision tester checked was 1E-9 as it is in many other contests and practice servers?
s
s-lime
You should have used double (16 digit precision) instead of float (6 digit precision). If even that isn't enough, you could use "long double".
n
n.vilcins
I used long double (actually there was no difference from double, that I submitted in the end), so that is not the case.

Maybe someone (using C++ for convinience) had a programme that really printed the values with 10 digit precision?
T
Tavo92
if you use cout:

cout.precision(10);
cout << fixed() << number << endl;

with printf I think is

printf("%.10f", &number);
t
thocevar
printf("%.10lf",number);

Format for double is 'lf'' and since you're not trying to print the address of a variable, drop the '&'. :)
n
n.vilcins
Thanks, that works.

Anyway the program I submitted printed with precision to 9 decimal places, therefore I think the grader should not have accepted these results.
m
matteo123
and you have in pascal comp (20 digit precision)
I have read it in my book of pascal