网上的很多代码都是错的
正确的代码
using ll = long long int;
ll is_mul_overflow(ll a,ll b)
{
if (a == -1)
return (b == INT64_MIN);
if (b == -1)
return (a == INT64_MIN);
if (a >= 0 and b >= 0)
return a == 0 ? 0 : INT64_MAX / a < b;
if(a < 0 and b < 0)
return INT64_MAX / a > b;
if (b < 0)
return INT64_MIN / b < a;
else
return INT64_MIN / a < b;
}