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 containing three integers A, B and C, separated by single spaces.

Output Specification:

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).

Sample Input:
3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0
Sample Output:
Case #1: false
Case #2: true
Case #3: false
思路
  • a,b,c的范围就知道就算使用long long也是要溢出的,这里我尝试取巧地使用了long doubledouble在我的codeblock上是8字节,而long double是12字节,不知道OJ上的是怎么样的,试着用一下还过了…
代码
#include<bits/stdc++.h>
using namespace std; int main()
{
int n;
long double a,b,c;
cin >> n;
for(int i=1;i<=n;i++)
{
cin >> a >> b >> c;
if(a + b > c)
cout << "Case #" << i <<": true" << endl;
else
cout << "Case #" << i <<": false" << endl;
}
return 0;
}
引用

https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336

PTA(Advanced Level)1065.A+B and C的更多相关文章

  1. PTA(Advanced Level)1036.Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  2. PTA (Advanced Level) 1004 Counting Leaves

    Counting Leaves A family hierarchy is usually presented by a pedigree tree. Your job is to count tho ...

  3. PTA (Advanced Level) 1020 Tree Traversals

    Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. Given the ...

  4. PTA(Advanced Level)1025.PAT Ranking

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

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

    因为会溢出,因此判断条件需要转化.变成b>c-a #include<cstdio> #include<cstring> #include<cmath> #in ...

  6. PTA (Advanced Level) 1009 Product of Polynomials

    1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomial ...

  7. PTA (Advanced Level) 1008 Elevator

    Elevator The highest building in our city has only one elevator. A request list is made up with Npos ...

  8. PTA (Advanced Level) 1007 Maximum Subsequence Sum

    Maximum Subsequence Sum Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous su ...

  9. PTA (Advanced Level) 1006 Sign In and Sign Out

    Sign In and Sign Out At the beginning of every day, the first person who signs in the computer room ...

随机推荐

  1. JAVA中java.lang.OutOfMemoryError常见的解决方式

    在开发中我们很多人都遇到过内存溢出的情况,其实内存溢出分几种形式: 1.tomcat中java.lang.OutOfMemoryError: PermGen space异常处理(最常见的) 概念大家可 ...

  2. White Sheet

    C - White Sheet 思路:先看代码,分成了四个条件.第一个和第二个表示的都是当白矩形存在某个黑矩形内部的情况. 另外就是:白矩形位于两个黑矩形的并集区域. 即可分为两种情况,一种是白矩形位 ...

  3. django 网站上传资源的显示与配置

    1.  上传资源的配置 1. 首先在项目里创建一个名称叫media的文件夹专门保存用户上传 2. settings.py文件配置上传资源的路径 # 上传资源路径,如果图片,上传文件等 MEDIA_UR ...

  4. 小程序支持npm包

  5. 【转】composer proc_open(NUL)报错问题

    composer  执行的时候报错错误信息如下: [ErrorException] proc_open(NUL): failed to open stream: No such file or dir ...

  6. Jsp中的四个域对象

    四个域对象: pageContext      page域 request          request域 session          session域 application       ...

  7. 动态执行文本vba代码

    动态执行文本vba代码 Public Sub StringExecute(s As String) Dim vbComp As Object Set vbComp = ThisWorkbook.VBP ...

  8. Selenium 2自动化测试实战26(unittest单元测试框架)

    一.unittest单元测试框架 1.认识单元测试 1.断言方法 #计算器类 #coding:utf-8 #计算器类 class Count: def __init__(self,a,b): self ...

  9. python 学习笔记(一):在列表、字典、集合中根据条件筛选数据

    一.在列表中筛选数据 在列表中筛选出大于等于零的数据,一般通用的用法代码如下: data = [3, -9, 0, 1, -6, 3, -2, 8, -6] #要筛选的原始数据列表 result = ...

  10. zabbix(2)使用指南

    一.邮件报警(一个客户端安装server,agent) 管理->报警媒介类型->email 管理->用户->Admin->报警媒介 配置->动作->Repor ...