Written by razrlele
	   15:35                      February 12, 2015 
不需要建树,直接遍历,如果平衡就返回正常值,否则返回0.
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61  | 
						/********************************************************     * File Name: uvaoj839.cpp     * Author: razrLeLe     * Mail: razrlele@gmail.com     * Homepage: https://yueyu.io     * Created Time: Wed 11 Feb 2015 12:16:55 PM CST  ******************************************************/ #include "vector" #include "set" #include "deque" #include "queue" #include "algorithm" #include "functional" #include "iostream" #include "cstdio" #include "cmath" #include "cstdlib" #include "string" #include "cstring" #include "string.h" #include "map" #include "cctype" #include "list" #include "stack" using namespace std; #define INF 0x3f3f3f3f #define LOCAL int solve() {     int wl, dl, wr, dr;     scanf("%d%d%d%d", &wl, &dl, &wr, &dr);     wl = (!wl)? solve():wl;     wr = (!wr)? solve():wr;     if(wl && wr &&wl*dl == wr*dr)     return wl+wr;     return 0;  } int main() { #ifdef LOCAL     freopen("/home/razrlele/build/data.txt", "r", stdin);     freopen("/home/razrlele/build/out.txt", "w", stdout); #endif     int numcase;     scanf("%d", &numcase);     while(numcase--)     {         if(solve())         printf("YES\n");         else         printf("NO\n");         if(numcase)         printf("\n");     }     return 0; }  |