标签:java 个数 one name for 分析 bin 溢出 div
Given three integers A, B and C in [−], you are supposed to tell whether A+B>C.
The first line of the input gives the positive number of test cases, T (≤). Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.
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).
3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0
Case #1: false
Case #2: true
Case #3: false
给定三个数A B C,A + B > C为true,否则为false
要考虑溢出的问题,我这里用 long double 接收输入
A B C同除1000,然后直接作比较
#include <iostream> using namespace std; int main() { long double A, B, C; int N; cin >> N; for (int i = 1; i <= N; ++i) { cin >> A >> B >> C; A /= 1000; B /= 1000; C /= 1000; cout << "Case #" << i << ": "; if (A + B > C) { cout << "true" << endl; } else { cout << "false" << endl; } } return 0; }
PAT 甲级 1065.A+B and C C++/Java
标签:java 个数 one name for 分析 bin 溢出 div
原文地址:https://www.cnblogs.com/47Pineapple/p/12266778.html