标签:style blog color io for div amp log
1 #include <stdio.h> 2 3 int main() { 4 long n, a, b, c; 5 long i; 6 int ga, gb, gc, r; 7 scanf("%ld", &n); 8 for (i=0; i<n; i++) { 9 scanf("%ld%ld%ld", &a, &b, &c); 10 ga = a >= 0; 11 gb = b >= 0; 12 gc = c >= 0; 13 if (ga && gb) { 14 if (gc) { 15 r = a > c - b; 16 } else { 17 r = 0; 18 } 19 } else if (!ga && !gb) { 20 if (gc) { 21 r = 0; 22 } else { 23 r = a > c - b; 24 } 25 } else { 26 r = a + b > c; 27 } 28 printf("Case #%ld: %s\n", i+1, r ? "true" : "false"); 29 30 } 31 return 0; 32 }
纯C,bool都用不了,不习惯了。符号相反的数相加肯定不会溢出。水一发。
PAT 1065. A+B and C (64bit),布布扣,bubuko.com
标签:style blog color io for div amp log
原文地址:http://www.cnblogs.com/lailailai/p/3925967.html