Not so Mobile...Uva 839..

Cause I wanna to let my English become well, I wanna to use it in my  essay...

if it error,,please tell me,thx.

"It is very important! " ---by RUJIA LIU.

 1 #include <iostream>
 2 #include <string>
 3 #include<sstream>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 bool solve(int & W)
 8 {
 9         int w1,d1,w2,d2;
10         bool b1 = true, b2 = true ; // if false .. will no..
11         cin >> w1 >> d1 >> w2 >> d2;
12         if( !w1 ) b1 = solve( w1 );
13         if( !w2 ) b2 = solve( w2 ); // w2 and w1 will be changed, cause &W....
14         W = w1 + w2 ; // W is the w1 or w2..before...
15         return b1 && b2 && ( w1 * d1 == w2 * d2 );
16          // if it is not true , when return the function, the solve() function will make the main function print "NO\n"..
17         
18 }
19 
20 int main()
21 {
22         int T , W;
23         cin >> T ;
24         while( T -- ){
25                 if(solve(W)) cout << "YES\n"; else cout << "NO\n";
26                 if(T) cout << endl;
27         }
28         return 0;
29 }
View Code

 

posted on 2015-07-31 14:18  小松song  阅读(93)  评论(0)    收藏  举报

导航