92分 为什么直接判断范围会错呢?
查看原帖
92分 为什么直接判断范围会错呢?
1443888
Alecvbnm楼主2024/9/10 21:40
#include <bits/stdc++.h>

using namespace std;

bool between(long long b)
{
    return -2147483648 <= b && b <= 2147483647;
}

void solve()
{
    long long x1, x2, y1, y2;

    cin >> x1 >> x2 >> y1 >> y2;

    long long a = x1 * x2;
    long long b = y1 * y2;
    long long c = x1 * y2;
    long long d = y1 * x2;

    if (between(a) && between(b) && between(c) && between(d))
    {
        cout << "int";
    }
    else
    {
        cout << "long long int";
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    solve();

    return 0;
}
2024/9/10 21:40
加载中...