forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB0029.cpp
More file actions
29 lines (25 loc) · 682 Bytes
/
B0029.cpp
File metadata and controls
29 lines (25 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Problem Code: COMM3
#include <iostream>
#include <cmath>
using namespace std;
string threeWayCommunications(int R, int X1, int Y1, int X2, int Y2, int X3, int Y3){
float a = sqrt(pow(X1-X2, 2) + pow(Y1-Y2, 2));
float b = sqrt(pow(X2-X3, 2) + pow(Y2-Y3, 2));
float c = sqrt(pow(X3-X1, 2) + pow(Y3-Y1, 2));
if( (a<=R && b<=R) || (b<=R && c<=R) || (a<=R && c<=R) )
return "yes";
else
return "no";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T, R, X1, Y1, X2, Y2, X3, Y3;
cin >> T;
for(int i=1 ; i<=T ; i++){
cin >> R >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3;
cout << threeWayCommunications(R, X1, Y1, X2, Y2, X3, Y3) << endl;
}
return 0;
}