Back to General discussions forum
My code return value like 1.66214192E8. Help me how I can decided this problem.
Hi, thanks for your question!
I've peeked into your code and I think you can slightly simplify it:
area
function.Probably this will work since checker for this problem should allow results with floating point, i.e. if you answer
16.999999999999993 9999.500000001688 6861562.999999995
instead of
17 9999.5 6861563
I believe this should work (as long as difference is less than 1e-7
). Feel free to write more if this still
does not help!
UPD I've tried to modify your code in this manner and succeeded (perhaps, after changing println to print).
Hi. I've tried print area without rounding function but resull was the same. I wrote this function to avoid it. My code is working with input example data but don't work with test data.
It's my input:--------------------------and that's my answer:
16
3047 3635 8109 4366 7588 8477___________1.0595366500000002E7
8251 8528 8536 2520 1010 3432___________2.2478144E7
5782 5400 3772 6423 4584 2247___________3781541.9999999995
392 4956 7430 5494 62 4966______________123960.0000000069
3812 6928 4065 8896 597 115_____________2301715.4999999967
5934 3644 3749 4042 8009 1337___________2107472.5
2518 6260 9865 1054 8779 874____________3488088.0000000005
4485 4560 6273 8257 983 856_____________3162070.9999999986
503 1374 5811 7933 6868 5872____________8936325.499999998
2898 680 2800 6962 9576 3396____________2.1108682E7
7077 5509 7040 826 9551 5048____________5801399.5
2163 2069 1307 2027 3122 86_____________868863.0000000001
2900 7607 4645 9173 5863 5627___________4047579.0000000005
28 6365 7001 5839 4297 3869_____________7579557.000000001
1711 7195 4548 4510 4157 4123___________1073877.0000000002
7906 1233 9632 4945 2059 9182___________1.7712018999999996E7
Although, wiht example data all Ok.
I don't understand but now answer is correct.
> I don't understand but now answer is correct.
Probably it is because the method of calculation you used - Heron's Formula is less accurate for some kinds of triangles (it accumulates calculation error more than necessary). So for some input data sets the precision could be sufficient and for some other it is not :)
However I'm glad you've done this problem! Congratulations!