java的写法
import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int T = scan.nextInt();
while(T--!=0){
if(solve(new M(0))){
System.out.println("YES");
}else{
System.out.println("NO");
}
if(T!=0)System.out.println();
}
}
private static boolean solve(M w) {
M wl = new M(scan.nextInt());
M dl = new M(scan.nextInt());
M wr = new M(scan.nextInt());
M dr = new M(scan.nextInt());
boolean b1 = true,b2 = true;
if(wl.value==0)b1 = solve(wl);
if(wr.value==0)b2 = solve(wr);
w.value = wl.value+wr.value;
return b1&&b2&&wl.value*dl.value==wr.value*dr.value;
}
static class M{
public int value;
public M(int value){
this.value = value;
}
}
}