Given three integers $A$, $B$ and $C$ in $[−2^{63},2^{63}]$, you are supposed to tell whether $A+B>C$.
The first line of the input gives the positive number of test cases, $T (\leqslant 10)$. Then $T$ test cases follow, each consists of a single line containing three integers $A$, $B$ and $C$, separated by single spaces.
For each test case, output in one line Case #X: true
if $A+B>C$, or Case #X: false
otherwise, where $X$ is the case number (starting from 1).
3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0
Case #1: false
Case #2: true
Case #3: false
本题 20 分,主要难点在使用 C/C++ 时 64位整数相加减可能会存在溢出的问题,需要讨论溢出的条件。Python 支持大整数,不用讨论。
count = int(input())
numbers = [map(int, input().split()) for _ in range(count)]
for i, (a,b,c) in enumerate(numbers):
if a + b > c:
print('Case #{}: true'.format(i+1))
else:
print('Case #{}: false'.format(i+1))
1065. A+B and C (64bit) (20)-PAT甲级真题_柳婼 の blog-CSDN博客