CHEFADD - EDITORIAL

Glad you found it useful.

Add two numbers in binary form.

1010

0110

you’ll see, that sum is 10000. This happened due to carry forward at bit index 1, 2 and 3 (counting from least significant to most significant). Analyse this example and you’ll get it.

can you please give one more example explaining this x, cf and y.

Other examples would be similar. I recommend you read and Binary Arithmetic (specifically Binary addition), which you may find by googling.

tester solution

This solution is showing runtime error(sigtstp)
I think its because of declaring such big array.
Its having time complexity of O(10^9).

What is the brute force approach that would solve one sub task?

@taran_1407 In recursive function, if we add an extra condition bit_a==0 && bit_b==0 return 0; produces WA. Can anyone explain the reason?

Please dont make fun of me or taran!

I did not get what you want to say.

In your solution, if we add an extra condition in recursive function ans
a == 0&& b== 0 return 0 gives WA. Why ?
and why do we need to add condition bit==B ??

I couldn’t understand your code

Because cf may be balancing the remaining bits as required for c.

Like, suppose we have a==0 && b==0. we need the current bit to be 1, and cf is also 1. Hence, This bit we get from cf. Assuming all next bits are 0, we have one way which, due to that condition, will be missed.

1 Like

tester program give time limit exceed @admin

Almost similar problem A. XOR Equation.

@taran_1407 Thanks :slight_smile: