POINT - editorial

Problem link :

Author :
aimon123

Explanation:
The minimum distance from C to AB is perpenducilar distance d . If d=0 , then solution doesn’t exist ,that means C exist into AB and so print yes. Otherwise print no and in next line print the perpendicular distance d .

Solution in cpp:

#include<bits/stdc++.h>
using namespace std;
#define ss second
typedef vector vd;
#define yes printf(“YES\n”)
#define no printf(“NO\n”)
int32_t main()
{
int t,i;
cin>>t;
for(i=1;i<=t;i++)
{
int j,a,b,c,d,q,m,n,p;
cout<<"Test case : "<<i<<endl;
cin>>a>>b>>c>>d;
m=b-d;
n=c-a;
p= - (m * a ) - (n * b);
double s = m * m + n * n ;
cin>>q;
while(q–)
{
int e,f;
cin>>e>>f;
double z = e * m + f * n + p;
if(z==0)
yes;
else
{
no;
double x;
x=abs(z)/sqrt(s);
cout<<fixed<<setprecision(6)<<x<<endl;
}
}
}
}