服了,搞半天,原来是我long存的数据太小,不得不用BigIntger了。
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
// long a = sc.nextLong();
// long b = sc.nextLong();
// long c = sc.nextLong();
BigInteger a = new BigInteger(sc.next());
BigInteger b = new BigInteger(sc.next());
BigInteger c = new BigInteger(sc.next());
if (isTriangle(a, b, c)) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
public static boolean isTriangle(BigInteger a, BigInteger b, BigInteger c) {
// return a + b > c && a + c > b && b + c > a;
return a.add(b).compareTo(c) > 0 && a.add(c).compareTo(b) > 0 && b.add(c).compareTo(a) > 0;
}