标签:c++ iostream namespace 编程 博客
2 10 10 8 8 8 8 10 10
Escape is possible. Box cannot be dropped.
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int N;
cin>>N;
while(N--)
{
double a, b, n, m, temp;
cin>>a>>b>>n>>m;
if(a > b)
{
temp = a;
a = b;
b = temp;
}
if(n > m)
{
temp = n;
n = m;
m = temp;
}
double x, y;
if(a >= n && b >= m)
{
cout<<"Escape is possible."<<endl;
continue;
}
else if((n > a && m > b) || (n > a && m < b))
{
cout<<"Box cannot be dropped."<<endl;
continue;
}
else
{
double c = sqrt(a * a + b * b);
if(c <= m)
{
cout<<"Box cannot be dropped."<<endl;
continue;
}
y = ((2 * a * n * n + sqrt((-4) * n * n * m * m *(a * a - m * m - n * n)))) / (2 * (n * n + m * m));
x = sqrt(n * n - y * y);
if(b - sqrt( m * m - (a - y) * (a - y)) >= x)
{
cout<<"Escape is possible."<<endl;
}
else
cout<<"Box cannot be dropped."<<endl;
}
}
return 0;
}
标签:c++ iostream namespace 编程 博客
原文地址:http://blog.csdn.net/liuchang54/article/details/43538285