标签:
| Time Limit: 1000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
| input | output |
|---|---|
10 10 10 1 2 1 2 5 |
YES |
8 4 1 1 2 1 3 1 |
NO |
以前做过类似的题,只是把二维的问题搬到空间上来,处理出与托盘接触的平面中,碗的截面就好了,两个圆分别放在两个边角,判断距离与大半径的关系就好了。
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const double esp = 0.00001;
struct Point
{
double x;
double y;
Point(double xx, double yy) :x(xx), y(yy){}
};
double dis(Point a, Point b)
{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
int main()
{
double a, b, d;
double r1, R1, r2, R2, h;
double rr1, rr2;
while (cin >> a >> b >> d)
{
cin >> r1 >> R1;
cin >> r2 >> R2;
cin >> h;
rr1 = r1*(h - d) / h + R1*d / h;
rr2 = r2*(h - d) / h + R2*d / h;
if (h <= d)
{
rr1 = R1;
rr2 = R2;
}
if (2 * rr1 > a || 2 * rr1 > b|| 2 * rr2 > a || 2 * rr2 > b)
{
cout << "NO" << endl;
continue;
}
Point p1(rr1, rr1);
Point p2(a - rr2, b - rr2);
double dd = dis(p1, p2);
if (dd >= R1 + R2)
{
cout << "YES" << endl;
}
else
cout << "NO" << endl;
}
}标签:
原文地址:http://blog.csdn.net/qq_18738333/article/details/45160063