Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner in = new Scanner(System.in);
- long testcases = in.nextLong();
- for(int i = 0; i < testcases; i++){
- Node start = new Node();
- if(start.Balanced())
- System.out.println("YES");
- else
- System.out.println("NO");
- System.out.println();
- }
- }
- }
- class Node {
- public long Wl, Dl, Wr, Dr;
- public Node(){
- Scanner in = new Scanner(System.in);
- Wl = in.nextLong();
- Dl = in.nextLong();
- Wr = in.nextLong();
- Dr = in.nextLong();
- }
- public boolean Balanced(){
- if(WeightL() * Dl == WeightR() * Dr){
- return true;
- }
- else return false;
- }
- public long WeightL(){
- if(Wl == 0){
- Node child = new Node();
- Wl = child.WeightL() + child.WeightR();
- }
- return Wl;
- }
- public long WeightR(){
- if(Wr == 0){
- Node child = new Node();
- Wr = child.WeightL() + child.WeightR();
- }
- return Wr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement