1065. A+B and C (64bit)

 1 #include<stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5     long long a,b,c,sum;
 6     int n,i;
 7     while(scanf("%d",&n)!=EOF)
 8     {
 9          for(i=1;i<=n;i++)
10          {
11            getchar();
12            scanf("%lld%lld%lld",&a,&b,&c);
13             sum = a + b;
14             int ifis;
15             if(a>0&&b>0&&sum<0) ifis=1;
16             else if( a<0 && b<0 && sum>=0 ) ifis=0;//  越界第一个值(全1)补码为 0
17             else if ( sum > c ) ifis=1;
18             else if ( sum <= c ) ifis =0;
19
20             if( ifis == 0) printf("Case #%d: false\n",i);
21             else printf("Case #%d: true\n",i);
22          }
23
24     }
25
26    return 0;
27 }
时间: 2024-08-09 14:41:57

1065. A+B and C (64bit)的相关文章

PAT 1065 A+B and C (64bit) (20)

1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives the po

PAT 1065. A+B and C (64bit)

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

1065 A+B and C (64bit) (20 分)大数 溢出

1065 A+B and C (64bit) (20 分) Given three integers A, B and C in [?2?63??,2?63??], you are supposed to tell whether A+B>C. Input Specification: The first line of the input gives the positive number of test cases, T (≤10). Then T test cases follow, ea

PAT (Advanced Level) 1065. A+B and C (64bit) (20)

因为会溢出,因此判断条件需要转化.变成b>c-a #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; long long a,b,c; int main() { int T; scanf("%d",&T);

PAT甲题题解-1065. A+B and C (64bit) (20)-大数溢出

第一眼以为是大数据,想套个大数据模板,后来发现不需要.因为A.B.C的大小为[-2^63, 2^63],用long long 存储他们的值和sum. 接下来就是分类讨论:如果A > 0, B < 0 或者 A < 0, B > 0,sum不会溢出,直接和C判断比较即可.如果A > 0, B > 0,sum可能会溢出, 溢出的话为负数,所以sum < 0时候说明溢出了,那么肯定是大于C的.如果A < 0, B < 0,sum可能会溢出,同理,sum &g

1065. A+B and C (64bit) (20)

Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives the positive number of test cases, T (<=10). Then T test cases follow, each consists of a single line co

PAT:1065. A+B and C (64bit) (20) AC

#include<stdio.h> #include<stdlib.h> int main() { int n; scanf("%d",&n); for(int i=1 ; i<=n ; ++i) { long long a,b,c; scanf("%lld%lld%lld",&a,&b,&c); long long sum=a+b; //[思维]:判断sum是否正负溢出,溢出的话不能直接按计算判断! i

pat(A) 1065. A+B and C (64bit) (java大数)

代码: import java.util.*; import java.math.*; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); int t=cin.nextInt(); for(int i=1;i<=t;i++) { BigInteger a,b,c; a=cin.nextBigInteger(); b=cin.nextBigInteger()

[A]1065 A+B and C (64bit)(挖坑待填)

Given three integers A, B and C in [-2^63, 2^63], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives the positive number of test cases, T (<=10). Then T test cases follow, each consists of a single line