`
java-mans
  • 浏览: 11430122 次
文章分类
社区版块
存档分类
最新评论

839 - Not so Mobile

 
阅读更多
/*
解题思路:
创建二叉树
遍历检查

这道题其实不需要建立树的结构,因为遍历检查可以在创建时就能完成
需要用到数组做存储结构
*/
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

struct Node
{
	int w1,d1,w2,d2;
	Node *lchild,*rchild;
};
bool isEqual;

Node *createTree()
{
	int w1,d1,w2,d2;
	cin>>w1>>d1>>w2>>d2;
	Node *root=(Node *)malloc(sizeof(Node));
	root->w1=w1;
	root->d1=d1;
	root->w2=w2;
	root->d2=d2;
	if(w1==0)
		root->lchild=createTree();
	else
		root->lchild=NULL;
	if(w2==0)
		root->rchild=createTree();
	else
		root->rchild=NULL;
	return root;
}

int check(Node *root)
{
	if(root->lchild!=NULL)
		root->w1=check(root->lchild);
	if(root->rchild!=NULL)
		root->w2=check(root->rchild);
	if(isEqual==true)																//这里有个技巧******
		isEqual=(root->w1*root->d1==root->w2*root->d2);
	/*		另一种表示形式
	if(root->w1*root->d1!=root->w2*root->d2)
		isEqual=false;
	*/
	return root->w1+root->w2;
}


int main()
{
	//freopen("data.in","r",stdin);
	int T;
	cin>>T;
	while(T--)
	{
		Node *root=createTree();
		isEqual=true;
		check(root);
		cout<<(isEqual?"YES":"NO")<<endl;
		//The outputs of two consecutive cases will be separated by a blank line.
		if(T!=0)//仔细看题,WA原因
			cout<<endl;
	}
	return 0;
}


分享到:
评论

相关推荐

    Easy Mobile Pro 2.2.2

    This makes Easy Mobile Pro the first Unity plugin ever to offer a truly cross-platform API for Turn-Based and Real-Time multiplayer on iOS and Android - one that not only combines, but actually ...

    Packt.Machine.Learning.for.Mobile.1788629353.rar

    You will master supervised and unsupervised learning algorithms, and then learn how to build a machine learning model using mobile-based libraries such as Core ML, TensorFlow Lite, ML Kit, and Fritz ...

    Intelligent Mobile Projects with TensorFlow

    Get practical insights and exclusive working code not available in the TensorFlow documentation Book Description As a developer, you always need to keep an eye out and be ready for what will be ...

    AAA and Network Security for Mobile Access.pdf

    the topics of Mobile IP and IPsec, to which the reader may refer, so it would not be fair to fill this book with redundant information. Instead, the book provides just enough material on those topics ...

    jQuery Mobile

    jQuery Mobile is not yet in production—as of this writing, it is in its Alpha 4 release, with the beta coming soon. Even so, the library already has a broad set of features and is remarkably stable. ...

    Xamarin Mobile Application Development for iOS

    Xamarin Mobile Application Development for iOS is not just your normal everyday book on iOS app development. Everything is written for a point and not for effect, and therefore you will learn ...

    Sams Teach Yourself jQuery Mobile in 24 Hours

    &lt;&lt;Sams Teach Yourself jQuery Mobile in 24 Hours&gt;&gt; if your English is not so bad this book is good for you,and is worth to read

    FairyGUI-Unity-Plugin-3.4.0.zip

    - IMPROVED: Text-Brighter mechanism is removed, so FairyGUI-Text-Brighter.shader is removed. - IMPROVED: Add support for shrinking multi-line text. - IMPROVED: Improve Lua support. 3.2.0 - NEW: Add ...

    Translucent Image - High performance Blur behind UI 2.2.unitypackage

    /content/78464 半透明图像以最低的性能成本为...- While it is much faster than others, blurring is still a demanding effect, so it might not run smoothly on weaker mobile devices, more here 仅供学习使用

    Branches 3.3 - 像素人跳跳游戏 .zip

    * This package does not include Easy Mobile. * The use of Easy Mobile is totally optional, this template is fully functioning on its own. * There’s an option to disable premium features (UI ...

    Designing A Common Sense Approach to Web & Mobile Application Design

    Not present at time of photo 87 Drop Nice-to-Have Features 88 The Unnecessary Test 89 The 60-Second Deadline 90 Aim low 92 Interface Surgery 93 Reevaluate nice-to-have features later 98 Let ...

    Learn ECMAScript, 2nd Edition-Packt Publishing(2018).epub

    Understanding the fundamentals of JavaScript can not only help a person create interactive web applications but also help set up web servers, create mobile applications through frameworks such as ...

    Sortable前端框架

    unwanted touchmove events even when your finger is not moving, resulting in the sort not triggering. This option sets the minimum pointer movement that must occur before the delayed sorting is ...

    PowerUI - HTML/CSS Unity

    PowerUI is a GUI framework which lets you make your interfaces rapidly with standard HTML and CSS. Making interfaces has never been so simple, intuitive and actually fun! Check out the screenshots for...

    Mastering Ionic 2: The Definitive Guide [2017]

    8. Troubleshooting common (and not-so common) Ionic 2 bugs 9. Submitting apps to the Apple App & Google Play Stores So whether you're a novice or a veteran developer Mastering Ionic 2 will give you ...

    iOS7 Day-by-Day

    iOS7 is probably the most significant change to Apple's mobile operating system since the launch of the iPhone3G. Not only does it completely revamp the UI, but it also introduces loads of really ...

    ISO as CD-ROM

    In lab environments, I often run Virtual Machines, so it is not possible or often practical to burn an ISO file onto disc before I can use it. With this tool, I can just mount an ISO as a CD-ROM, and...

    英文原版-Effective Robotics Programming with ROS 3rd Edition

    then continues with more complex modules available in ROS such as sensors and actuators integration (drivers), navigation and mapping (so you can create an autonomous mobile robot), manipulation, ...

    Windows 8.1 Enterprise Device Management Protocol

    • The enrollment agent, which enrolls and configures the device so that it can communicate with an enterprise management service. • The management agent, which periodically synchronizes with the ...

Global site tag (gtag.js) - Google Analytics