PTA(Advanced Level)1065.A+B and C
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 double,double在我的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的更多相关文章
- 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 ...
- PTA (Advanced Level) 1004 Counting Leaves
Counting Leaves A family hierarchy is usually presented by a pedigree tree. Your job is to count tho ...
- PTA (Advanced Level) 1020 Tree Traversals
Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. Given the ...
- PTA(Advanced Level)1025.PAT Ranking
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- PAT (Advanced Level) 1065. A+B and C (64bit) (20)
因为会溢出,因此判断条件需要转化.变成b>c-a #include<cstdio> #include<cstring> #include<cmath> #in ...
- 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 ...
- PTA (Advanced Level) 1008 Elevator
Elevator The highest building in our city has only one elevator. A request list is made up with Npos ...
- PTA (Advanced Level) 1007 Maximum Subsequence Sum
Maximum Subsequence Sum Given a sequence of K integers { N1, N2, ..., NK }. A continuous su ...
- 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 ...
随机推荐
- 给PS添加ICO格式文件
为什么你的ps不能直接打开favicon.ico文件呢?因为你没有安装识别ico的格式插件. 安装步骤如下: 下载格式文件:https://pan.baidu.com/s/1lE0El1VtDqD5l ...
- 2018第九届蓝桥杯C/C++ A组试题答案参考
题目1 标题:分数 1/1 + 1/2 + 1/4 + 1/8 + 1/16 + .... 每项是前一项的一半,如果一共有20项,求这个和是多少,结果用分数表示出来.类似:3/2当然,这只是加了前2项 ...
- 灰度图像--图像分割 Marr-Hildreth算子(LoG算子)
学习DIP第49天 转载请标明本文出处:*http://blog.csdn.net/tonyshengtan *,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发: https:/ ...
- D. Make a Permutation!(思维)
D. Make a Permutation! time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Idea中使用Maven编码打包时中文乱码的解决办法
-Dfile.encoding=GBK
- How to correctly set application badge value in iOS 8?
o modify the badge under ios8 you have to ask for permissions let settings = UIUserNotificationSetti ...
- vue 打包部署到服务器上 配置nginx访问
坑一 css,js资源引入不正确 webpack配置文件config/index.js 需要更改: 方法一 当部署到带有文件夹的项目中,这种绝对路径就会出现问题,因为把配置的static文件夹当成了根 ...
- 11.二进制中1的个数 Java
题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 思路 当n不等于0时执行以下循环: 1.判断n的最低位是否为1,若为1,则计数器加1 2.将n无符号右移1位(若使用带符号移 ...
- Nginx事件管理之概念描述
1. Nginx事件管理概述 首先,Nginx定义了一个核心模块ngx_events_module,这样在Nginx启动时会调用ngx_init_cycle方法解析配置项,一旦在 nginx.conf ...
- 关于colab的一些技巧
1.指定工作文件夹(运行可以相对路径!) # 指定当前的工作文件夹 import os # 此处为google drive中的文件路径,drive为之前指定的工作根目录,要加上 os.chdir(&q ...