-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathURI_1124.cpp
36 lines (29 loc) · 861 Bytes
/
URI_1124.cpp
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
30
31
32
33
34
35
36
#include <iostream>
#include <cmath>
#include <vector>
class shape
{
int x, y;
public:
shape(int _x, int _y) : x(_x), y(_y) {}
double Distance(const shape& OtherShape);
};
double shape::Distance(const shape& OtherShape)
{
return sqrt(pow(x - OtherShape.x, 2) + pow(y - OtherShape.y, 2));
}
int main()
{
int width, length, r1, r2;
while(std::cin>>width>>length>>r1>>r2 && (r1 && r2))
{
shape Cylinder1(r1, length - r1), // First cylinder at the top left corner
Cylinder2(width - r2, r2); // Second cylinder at the bottom right corner
double distance = Cylinder2.Distance(Cylinder1);
if(distance < r1 + r2 || (r1 > width / 2.f || r1 > length / 2.f || r2 > width / 2.f || r2 > length / 2.f))
std::cout<<"N\n";
else
std::cout<<"S\n";
}
return 0;
}