她将基于一个由
现在请问,
第一行一个整数,表示数据组数。对于每组数据格式为:
第一行一个整数,表示数组长度。
第二行个整数,第
个整数为
,表示每次移动的距离。
第三行四个整数,分别表示起点的横纵坐标,终点的横纵坐标。
数据保证单个测试文件。
对于每组数据输出一个字符串,若可以恰好移动到输出 "YES" ,否则输出"NO"。
2 2 0 0 1 1 1 1 3 1 1 1 1 1 2 2
YES NO
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int t = in.nextInt();
in.nextLine();
for(int i = 0;i < t;i++){
int n = in.nextInt();
in.nextLine();
long num1 = 0;
for(int j = 0;j < n;j++){
num1 += in.nextLong();
}
in.nextLine();
long a = in.nextLong();
long b = in.nextLong();
long c = in.nextLong();
long d = in.nextLong();
in.nextLine();
long num2 = Math.abs(c - a) + Math.abs(d - b);
if(num1 >= num2 && ((num1 - num2) % 2 == 0)){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
}
in.close();
}
}