微信网站 教程,创业项目网,订餐网站的数据库建设,专门做画册的网站题#xff1a;点我 题目大意#xff1a; 这题虽然看着像签到#xff0c;然鹅签不过去。 因为我最初写的沙雕代码是#xff1a;
#includeiostream
#includecstdio
using namespace std;
int main(void)
{int t;scanf(%d, t);for (int i …题点我 题目大意 这题虽然看着像签到然鹅签不过去。 因为我最初写的沙雕代码是
#includeiostream
#includecstdio
using namespace std;
int main(void)
{int t;scanf(%d, t);for (int i 0; i t; i){long long a, b, c;scanf(%lld%lld%lld, a, b, c);if (a b c){printf(Case #%d: false, i 1);}else{printf(Case #%d: true, i 1);}if(i!t-1)printf(\n);}
}这题的数据范围应该是用long long的然鹅一旦发生溢出就不能简单的用加法来表示了发生溢出的两种情况
两个正数相加之后是负数比如两个 2 31 − 1 2^{31}-1 231−1相加之后的结果是 − 2 32 -2^{32} −232这个负数到不了 0 0 0两个负数相加之后是正数比如 − 2 32 -2^{32} −232相加之后结果是 0 0 0
修改后代码
#includeiostream
#includecstdio
using namespace std;
int main(void)
{int t;scanf(%d, t);for (int i 0; i t; i){long long a, b, c;scanf(%lld%lld%lld, a, b, c);long long sumab;if (a 0 b 0 sum 0){printf(Case #%d: true, i 1);}else if (a 0 b 0 sum 0){printf(Case #%d: false, i 1);}else if (a b c){printf(Case #%d: false, i 1);}else{printf(Case #%d: true, i 1);}if(i!t-1)printf(\n);}
}