最长边大于其它两边之和的话,就截短为其它两边之和减一的长度:
import java.util.*; public class Main { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); int sum = a + b + c; int A = Math.max(Math.max(a, b), c); if(A >= sum - A) System.out.println(2*(sum - A) - 1); else System.out.println(sum); } }