PROBLEM LINK:
Author: unknown_9876
Tester: sourav472
Editorialist: sourav472
DIFFICULTY:
Easy
PREREQUISITES:
Basic Mathematics
EXPLANATION:
Whether triangle is possible or not, check ( larger side of triangle < sum of other two sides ) then triangle is possible otherwise not.
For find out the area of triangle, first find out semi perimeter (s=(a+b+c)/2), then sqrt of (s*(s-a)(s-b)(s-c)); Where a,b,c are three sides of triangle.
SOLUTIONS:
Setter's Solution
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll t;
cin>>t;
while(t--)
{
ll a,b,c,ar[3];
cin>>a>>b>>c;
long double s,ans,p;
ar[0] = a;
ar[1] = b;
ar[2] = c;
sort(ar,ar+3);
if(ar[0]+ar[1]<=ar[2])
cout<<"NO\n";
else
{
s = (a+b+c)/2;
p=1.00;
p*= sqrt(s);
p*=sqrt(s-a);
p*=sqrt(s-b);
p*=sqrt(s-c);
ans = p;
cout<<"YES "<<fixed<<setprecision(5)<<(ans)<<"\n";
}
}
return 0;
}
Tester's Solution"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define dfor(i,a,b) for(ll i=(a);i<(b);i++)
#define rfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define pii pair<ll,ll>
#define vi vector<ll>
#define vpii vector<pii>
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define fast ios_base::sync_with_stdio( false );cin.tie(NULL);
const ll mod = (ll)(1e9+7);
int main() {
fast
ll t;
cin>>t;
while(t--)
{
ll a,b,c,ar[3];
cin>>a>>b>>c;
long double s,ans,p;
ar[0] = a;
ar[1] = b;
ar[2] = c;
sort(ar,ar+3);
if(ar[0]+ar[1]<=ar[2])
cout<<"NO\n";
else
{
s = (a+b+c)/2;
p = s*(s-a)*(s-b)*(s-c);
ans = sqrt(p);
cout<<"YES "<<fixed<<setprecision(5)<<ans<<"\n";
}
}
return 0;
}