奇数除以2会有舍入误差,记得再加起来检验一下:

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt(), q = sc.nextInt(), m = sc.nextInt(), n = sc.nextInt();
        int A = (p + m)/2, B1 = (q + n)/2, B2 = (m - p)/2, C = (n - q)/2;
        if(B1 == B2 && A >= 0 && B1 >= 0 && C >= 0 && A - B1 == p && B1 - C == q && A + B1 == m && B1 + C == n){
            System.out.print(A);
            System.out.print(" ");
            System.out.print(B1);
            System.out.print(" ");
            System.out.print(C);
            return;
        }
        System.out.print("No");
    }
}