PAT甲级1065 A+B and C (64bit) (20分)|C++实现

一、题目描述

原题链接
在这里插入图片描述

Input Specification:

在这里插入图片描述

​​Output Specification:

在这里插入图片描述

Sample Input:

3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0

Sample Output:

Case #1: false
Case #2: true
Case #3: false

二、解题思路

这道题取了个巧,直接用long double存储数据,更科学的方法可以去参考柳神的解答,好像要重载大于号…

三、AC代码

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
    
    
  	int T;
  	long double a, b, c;
  	scanf("%d", &T);
  	for(int i=0; i<T; i++)
    {
    
    
      	scanf("%llf%llf%llf", &a, &b, &c);
      	if(a +  b > c)
          	printf("Case #%d: true\n", i+1);
      	else
          	printf("Case #%d: false\n", i+1);
    }
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42393947/article/details/108660435