老手的解法
2025-06-04 20:44:42
发布于:广东
18阅读
0回复
0点赞
#include <iostream>
#include <climits>
using namespace std;
int main() {
int xl, xu, yl, yu;
cin >> xl >> xu >> yl >> yu;
// 检查所有可能的极值组合是否可能溢出
bool overflow = false;
if ((long long)xl * yl < INT_MIN || (long long)xl * yl > INT_MAX) overflow = true;
if ((long long)xl * yu < INT_MIN || (long long)xl * yu > INT_MAX) overflow = true;
if ((long long)xu * yl < INT_MIN || (long long)xu * yl > INT_MAX) overflow = true;
if ((long long)xu * yu < INT_MIN || (long long)xu * yu > INT_MAX) overflow = true;
cout << (overflow ? "long long int" : "int") << endl;
return 0;
}
<协助人员DeepSeek>
全部评论 1
#include<bits/stdc++.h>
using namespace std;
signed main(void){
long long x1,x2,y1,y2;
cin>>x1>>x2;
cin>>y1>>y2;
if(x1y1<=-2147483647||x2y2>=2147483647){
cout << "long long int";
}else{
cout << "int";
}
return 0;
}2025-12-24 来自 浙江
0











有帮助,赞一个