为什么会错,求大佬讲解的详细一点

P1401 [入门赛 #18] 禁止在 int 乘 int 时不开 long long

```cpp #include<bits/stdc++.h> using namespace std; #define int long long int a,b,c,d; signed main(){ cin>>a>>b>>c>>d; if(a*c<-2147483648||a*c>2147483647||b*d<-2147483648||b*d>2147483647||a*d<-2147483648||a*d>2147483647||b*c<-2147483648||b*c>2147483647){ cout<<"long long int"; }else{ cout<<"int"; } return 0; } ``` 好好想一下判断的条件够不
by xtrxx @ 2024-09-01 18:04:36


感谢,好的
by difficultlong @ 2024-09-01 18:07:09


```cpp #include<bits/stdc++.h> using namespace std; long long a[5]; const long long p=2147483647,q=-2147483648; int main(){ for(int i=1;i<=4;i++){ scanf("%lld",&a[i]); } for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ if(i==j){ continue; } if(a[i]*a[j]>p||a[i]*a[j]<q){ printf("long long int"); return 0; } } } printf("int"); return 0; } ``` @[xtrxx](/user/1420512) 问一下,这为什么是错的呢
by difficultlong @ 2024-09-01 18:08:27


要是是这样呢 ``` 2147483647 2147483647 1 1 ```
by hyl_____ @ 2024-09-01 18:12:58


@[hyl_____](/user/1035028) 感谢
by difficultlong @ 2024-09-01 18:13:44


![](https://imgs.qiubiaoqing.com/qiubiaoqing/album_cover/65d89a3e60537cG4.jpg) 这代码我理解不了在干什么
by xtrxx @ 2024-09-01 18:13:46


true answer:`int` your answer:`long long int`
by hyl_____ @ 2024-09-01 18:14:04


你这个可能导致某个数的范围自乘
by hyl_____ @ 2024-09-01 18:14:40


|