PAT A1065 A+B and C (64bit)

总结:题目所给数据范围可以用long long 存数据,但是加法减法可能会溢出,这段代码是随便写的居然过了哈哈哈哈

代码:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long  a, b, c;
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b >> c;
        if ((a >= c&&b>0) || (b >= c&&a>0))cout << "Case #" << i + 1 << ": true" << endl;
        else if (a >c-b&&b>c-a)cout << "Case #" << i + 1 << ": true" << endl;
        else cout << "Case #" << i + 1 << ": false" << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/luoshiyong123/article/details/81365957