2525. 根据规则将箱子分类 - 力扣(LeetCode)
按题意书写即可,需要关注的就是设置数的大小。
class Solution {
public:
string categorizeBox(int length, int width, int height, int mass) {
bool flag1=false,flag2=false;
long long vol=(long) width*height*length;
if(mass>=1e4||height>=1e4||length>=1e4||width>=1e4||vol>=1e9){
flag1=true;
}
if(mass>=100){
flag2=true;
}
if(flag1&&flag2){
return "Both";
}
else if(flag1){
return "Bulky";
}
else if(flag2){
return "Heavy";
}
else{
return "Neither";
}
}
};