这道题的坑点在于给定数据的范围。
int 类型的数据大小是[-2^31 , 2^31 -1] 即 [-2147483648,2147483647]
本题给定数据的大小是[-2^31 , 2^31]正好比int类型的正数多了1,因此需要改变数据类型,扩大数能表示的范围。
代码:
#include <iostream>
using namespace std;
int main() {
int t = 0;
long long a = 0, b = 0, c = 0;
cin >> t;
int cnt = 1;
while (t--) {
cin >> a >> b >> c;
if (a + b > c)
cout << "Case #" << cnt << ": true" << endl;
else
cout << "Case #" << cnt << ": false" << endl;
cnt++;
}
return 0;
}