![:evil:](./images/smilies/icon_evil.gif)
My algorithm is to sort the sides in increasing order and using heron's formula to calculate the area.
I think there can be precise error and overflow, so i use long double, is anything wrong?? Please help me
![:(](./images/smilies/icon_frown.gif)
Code: Select all
Deleted after AC
Moderator: Board moderators
Code: Select all
Deleted after AC
Looks like this is because of sine rule 1/2*a*b*arcsin(b/e) < 1/2*c*d*arcsin(d/e) , sin and arcsin being ans increasing function.let a<b<c. Now a is very small but b and c are large. increasing a would increase the height of the triangle hence area until it is close to b .
Now when we choose c , why should "b" be the closest number to c ? Why can't we take a pair that satisfies (p,q) p<q<c where p and q are very close. Here i miss the insight.
Since p<a && q<b ,the height formed by them should be smaller is my guess. I think the difference (q-p) and (b-a) also counts in determining the height.
Code: Select all
inline int iseq(double x,double y){
if (fabs(x-y) < EPS) return true;
return false;
}
inline double area(double x,double y,double z){
if(x+y < z) return 0.0;
if(iseq(x+y,z)) return 0.0;
...
}
Code: Select all
Removed after AC.
Code: Select all
removed
Code: Select all
int comp(double *p,double *q)
{
return *q-*p;
}
.
.
.
ac , removed