1793. Tray 2
Memory Limit: 64 MB
Input
Output
Samples
input | output |
---|---|
10 10 10 1 2 1 2 5 |
YES |
8 4 1 1 2 1 3 1 |
NO |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
struct plate {
double r, R;
};
plate p1, p2;
int main()
{
double a, b, d, h, r, R, sqr, dr, dh;
bool flag = true;
scanf("%lf %lf %lf", &a, &b, &d);
scanf("%lf %lf", &p1.r, &p1.R);
scanf("%lf %lf", &p2.r, &p2.R);
scanf("%lf", &h);
if (p1.r*2 > a || p1.r > b || p2.r > a || p2.r > b)
flag = false;
else {
r = a - p1.r - p2.r;
R = b - p1.r - p2.r;
sqr = sqrt(r*r + R*R);
if (sqr < p1.r+p2.r)
flag = false;
else {
if (h > d) {
dr = p1.R - p1.r;
dh = h - d;
a += dr*dh/h;
b += dr*dh/h;
dr = p2.R - p2.r;
a += dr*dh/h;
b += dr*dh/h;
}
if (p1.R*2 > a || p1.R > b || p2.R > a || p2.R > b)
flag = false;
else {
r = a - p1.R - p2.R;
R = b - p1.R - p2.R;
sqr = sqrt(r*r + R*R);
if (sqr < p1.R+p2.R)
flag = false;
}
}
}
if (flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}