The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Devu is a little boy. He does not know how to take carries while adding two numbers in decimal base. eg. He will struggle in adding numbers 83 and 19, because
3 + 9 = 12 and he needs to take a carry of 1.
Â
You are given an integer n. Can you write it in terms of sum of two positive integers such that while adding them in base 10, Devu doesn't need to use any carries.
Â
Â
First line of the input contains an integer T denoting number of test cases.
Â
For each test case, there is a single line containing an integer n.
Â
Â
For each test case, print a single line YES or NO according to situation in the problem.
Â
Â
Â
Input: 2 1 9 Output: NO YES
Â
Example case 1. 1 can not written in desired way.
Â
Example case 2. 9 can be written as sum of 2 and 7. Devu doesn't need to use any carries here.
q2
You are given a rooted tree with N nodes. Tree is rooted at node 1. Each node of the tree contains some value. Initially value of each node will be given.
Â
You are given Q queries. Queries can be of two types, type U and type Q.
Â
Â
Â
First line of the input contains two space separated integers N and Q.
Â
For next N - 1 lines, each line contains two space separated integers u, v
denoting that there is an edge between u and v in the tree. It is guaranteed that 1 = u, v = N, u != v.
It is also guaranteed that no edge is repeated in the input.
Â
Next line contains N space separated integers denoting the initial weight of each node in order, 1 to N. Weights will be between -10^9 to 10^9 (both inclusive).
Â
For next Q lines, each line contains a query of either type U or type Q.
Â
Â
For each query of type Q, output a single line containing an integer corresponding to answer of the query.
Â
Â
Â
Input: 4 3 1 2 1 3 2 4 5 -2 0 3 Q 1 U 3 1 Q 1 Output: 1 0
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll