Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C Programming Language Problem Title: Powers of Two Adrian has learned addition and subtraction from Morgan and is now ready to learn a new

USE C Programming Language

Problem Title: Powers of Two

Adrian has learned addition and subtraction from Morgan and is now ready to learn a new concept, the powers of two. Powers of two are integers in the form of 2x, where x 0. Some examples of powers of two are 1, 2, 4, 8, . . . . To ensure Adrian understands this new concept, Morgan prepares a challenge for him. At first, Adrian is given an integer N = 0. Then, Morgan will give him Q queries. Each query can be one of the following types: + x, which will add the value of N by 2x, or - x, which will subtract the value of N by 2x. Adrian is instructed to clap his hands whenever N becomes 0 after each query. Adrian finds this challenge is very hard to follow. He asks you whether he should clap or not after each query.

Input Input begins with an integer Q (1 Q 200 000) representing the number of queries. Each of the next Q lines contains a character and an integer T x (T { +, - }; 0 x 200 000) representing the query.

Output After each query, output YES in a single line if the value of N becomes 0, or output NO otherwise.

Sample Input #1 6 + 3 + 3 - 4 - 6 + 7 - 6

Sample Output #1 NO NO YES NO NO YES

Sample Input #2 13 + 13324 + 5773 - 5772 + 13324 + 0 - 5772 - 13325 - 0 + 0 + 0 - 200000 - 1 + 200000

Sample Output #2 NO NO NO NO NO NO NO YES NO NO NO NO YES

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions