📄 1174.cpp
字号:
#include <iostream> //老师写的
#include <string>
using namespace std;
float findmax(float x,float y,float z)
{
if(x>=y&&x>=z)
return x;
if(y>=x&&y>=z)
return y;
return z;
}
float findmin(float x,float y,float z)
{
if(x<=y&&x<=z)
return x;
if(y<=x&&y<=z)
return y;
return z;
}
bool testx(float x1,float x2,float y1,float y2,float z1,float z2)
{
float temp,max,min;
if(x1>x2)
{
temp=x1;
x1=x2;
x2=temp;
}
if(y1>y2)
{
temp=y1;
y1=y2;
y2=temp;
}
if(z1>z2)
{
temp=z1;
z1=z2;
z2=temp;
}
max=findmax(x1,y1,z1);
min=findmin(x2,y2,z2);
if(max<=min)
return true;
else
return false;
}
int main()
{
int t;
while(cin>>t)
{
int i;
float v1,h1,x1,y1,z1;
float v2,h2,x2,y2,z2,gunx,guny,gunz;
float tx1,tx2,ty1,ty2,tz1,tz2;
for(i=0;i<t;i++)
{
cin>>v1>>h1>>x1>>y1>>z1;
cin>>v2>>h2>>x2>>y2>>z2>>gunx>>guny>>gunz;
tx1=(x2-x1+h1)/gunx;
tx2=(x2-x1-h1)/gunx;
ty1=(y2-y1+h1)/guny;
ty2=(y2-y1-h1)/guny;
tz1=(z2-h2*0.1-z1+h1)/gunz;
tz2=(z2-h2*0.1-z1-h1)/gunz;
if(testx(tx1,tx2,ty1,ty2,tz1,tz2))
{
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
}
}
return 0;
}
/*更正一下:
tz1=(z2-h2*0.1-z1+h1)/gunz;
tz2=(z2-h2*0.1-z1-h1)/gunz;
换成
tz1=(z2-h2*0.1-z1)/gunz;
tz2=(z2-h2*0.1-z1-2*h1)/gunz;*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -