I think the test case 2 should be updated. Because we know sum of two sides of a triangle must be greater than the third side. I submitted my code with this theory but I got wrong answer. But when I submitted my code with the wrong theory I got AC.
The wrong theory:
a+b>=c
a+c>=b
b+c>=a
Anything that returns positive real number in the equation s = root(s * (s - a) * (s - b) * (s - c)) has been considered the sides of a correct triangle for this problem.
@touhidur Still have the problem… I know there are some syntax that are not necessary. But when I started getting WA again and again I added those.
Please check again
How can a be less than 0? You don’t need to check these kind of stuffs.
if (s > 0) {
printf("%0.2lf\n", sqrt(s * (s - a) * (s - b) * (s - c)));
} else {
printf("Oh, No!\n");
}
And you should read previous post carefully. Like I said before here, anything that raturns a positive real number in that equation is considered to be valid here. Even if s = 0. So, remove it also.
And please, if you want your code to reveiwed, please format it carefully just like you have before here. Otherwise, it is hard to read them. You should edit your post(s) now and format the codes properly. So that the people who read these posts after you from now on can be helped.
I think I had told you to format your codes correctly if you want them to be reveiwed.
Please follow (or at least try to follow) previous instruction(s) before you do them yourself.
import math
N=int(input())
A={}
no={}
for i in range(N):
a, b, c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b<=c or a+c<=b or b+c<=a:
no[i]=1
else:
no[i]=0
s=(a+b+c)/2
s1=s-a
s2=s-b
s3=s-c
if no[i]==0:
A[i]=math.sqrt(ss1s2*s3)
for i in range(N):
if no[i]==1:
print(‘Oh, No!’)
if no[i]==0:
print(“%.2f” % A[i])
< and <= works differently that’s why. And also I have described the reason quite a number in the previous so please read them carefully.
try to search for them to learn more.
And again please format your codes correctly before posting them in the community.
You can use this post as a reference.