Given three integers , and in , you are supposed to tell whether .
The first line of the input gives the positive number of test cases, . Then test cases follow, each consists of a single line containing three integers , and , separated by single spaces.
For each test case, output in one line Case #X: true
if , or Case #X: false
otherwise, where 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博客