互斥原理
参考:https://blog.nowcoder.net/n/7fd707689ab44145b696f5a28ac0f829
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T=in.nextInt();
while(T-->0){
long n=in.nextLong();
long a=in.nextLong();
long b=in.nextLong();
long c=in.nextLong();
long d=in.nextLong();
long res=(a+b+c-d-n)/2;
System.out.println(res);
}
}
}

京公网安备 11010502036488号