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 ...
随机推荐
- nginx 入门实战
nginx入门实战 nginx 安装与卸载 下载安装 进入 http://nginx.org/en/download.html 下载自己想要的版本,我选择的stable版本 tar -zxvf ngi ...
- 使用Python画一朵玫瑰花
# -*- coding: utf-8 -*- # @Time : 18-9-14 下午12:47 # @Author : Felix Wang from turtle import * import ...
- Plx9030通讯卡驱动开发与接口封装
在学校的时候,曾经采用DDK+Driverstudio+VC6.0环境做过9054视频采集卡的驱动开发,回想起调试过程,记得最清楚的就是过无数次的计算机蓝屏重启....今天第一天来到新公司,老大就说你 ...
- Linux之vnc启动及异常处理
1)启动桌面1的服务 [root@testdb ~]# vncserver :1 New 'testdb:1 (root)' desktop is testdb:1 Starting applicat ...
- js计算textarea输入文字的长度
前言 日常开发过程中,有些时候我们想使用textarea,然后限制输入的长度,在textarea末尾显示剩余可输入的字节数. 如下图: 解决方法: 常用的有三种方法: 1.通过判断charCodeA ...
- sql注入的基本小知识
load_fie('') into outfile '' into dumpfile('') 堆叠注入 ;insert into liunx密码读取 /etc/passwd /etc/shadow W ...
- $\LaTeX$数学公式大全6
$6\ Binary\ Operation/Relation\ Symbols$$\ast$ \ast$\star$ \star$\cdot$ \cdot$\circ$ \circ$\bullet$ ...
- DB 分库分表(4):多数据源的事务处理
系统经sharding改造之后,原来单一的数据库会演变成多个数据库,如何确保多数据源同时操作的原子性和一致性是不得不考虑的一个问题.总体上看,目前对于一个分布式系统的事务处理有三种方式:分布式事务.基 ...
- Python代码整洁之道(一)
很多新手在开始学一门新的语言的时候,往往会忽视一些不应该忽视的细节,比如变量命名和函数命名以及注释等一些内容的规范性,久而久之养成了一种习惯.对此呢,我特意收集了一些适合所有学习 Python 的人, ...
- git commit 合并到指定分支
1. 将指定的commit合并到当前分支 git cherry-pick commit_id 2. 合并多个连续 commit 到指定分支 假设需要合并 devlop 上从 fb407a3f 到 9 ...