题解:UVA12696 Cabin Baggage
本题要求判断行李箱是否合法。输入 ,,, 四个浮点数,代表行李箱的长,宽,高,重量。满足以下要求则行李箱合法:
-
,, 或者 。
-
。
多组数据,对于每组数据,如果行李箱合法输出一,否则输出零。在最后输出满足要求的行李箱数。
没什么好说的,按照题意模拟,注意变量定义的类型。
上代码!
#include<bits/stdc++.h>
using namespace std;
int cnt,t;
int main(){
cin>>t;
while(t--){
double length,width,depth,weight;
cin>>length>>width>>depth>>weight;
if((length<=56&&width<=45&&depth<=25 || length+width+depth<=125) && weight<=7){
cout<<1<<endl;
cnt++;
}
else cout<<0<<endl;
}
cout<<cnt<<endl;
return 0;
}