题意
判断a+b
是否大于c
?
思路
emmmm。对不起出题人,我还是直接上int64_t
了,顺便整个BigInteger
。杀鸡用牛刀。。。。
代码
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T;
cin >> T;
for (int cas = 1; cas <= T; ++cas) {
int64_t a, b, c;
cin >> a >> b >> c;
if (a + b > c)
cout << "Case #" << cas << ": true\n";
else
cout << "Case #" << cas << ": false\n";
}
return 0;
}
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T;
T = in.nextInt();
for (int cas = 1; cas <= T; ++cas) {
BigInteger a = in.nextBigInteger();
BigInteger b = in.nextBigInteger();
BigInteger c = in.nextBigInteger();
if (a.add(b).compareTo(c) > 0) {
System.out.println("Case #" + cas + ": true");
}
else {
System.out.println("Case #" + cas + ": false");
}
}
}
}
HINT
不定时更新更多题解,Basic Level 全部AC代码,详见 link ! ! !