Help

For product and xor of two number find and of two number.Problem is for product and xor of two numbers find two number, but if i have and of two number i can solve a problem. Thank you.
this isn't a coding problem, it a properties of integer problem.
you need to study exactly what xor means and does. and you may need to review multiply, which you probably think you understand, but in terms of its effect on binary numbers, maybe you do not fully grasp some of the properties.

but start with xor.

if I give you the number
10110 what can be xored to get this result?

10110
00000 the trivial case. 0 has no effect on xor. 1^0 is 1. 0^0 is 0. here, honestly, if product is 0, you have the answer without any real work.

11111 //another trivial case.
01001

but if you look at this there are only fairly small number of numbers that can produce this result. Find the pairs that can be xored to give the result programmatically, and then multiply them to see which pair it was. Then you have A and B, so you can finish up. Hint: the xor swap algorithm shows you an important property of tying 3 numbers together with xor (2 inputs and the output) and can be used to figure out A&B

From the web as part of the lead up to a solution to a similar problem:
A simple solution is to generate all possible pairs with given XOR. To generate all pairs, we can follow below rules.
If X[i] is 1, then both a[i] and b[i] should be different, we have two cases.
If X[i] is 0, then both a[i] and b[i] should be same. we have two cases.
So we generate 2^n possible pairs where n is number of bits in X.
Last edited on
Can you do problem because i need it for school homework?Thank you.p
I think you meant, "here is what I wrote, and its close, but not quite working, can you help me". Surely you didn't mean to imply that you would cheat on your schoolwork? People like that get hired and we have a big long process of getting them settled in, figure out they are morons who can't do the work, firing them, and another big long process of hiring someone else. You don't want to be that guy!
Last edited on
I understand that is xor if number is 0 then number is equal, but i dont no what to do in other cases. This solution for 2^n i know it but is very slow.
Last edited on
Can you do problem because i need it for school homework?

Homework questions are for you to work out, so that you will learn from the experience. If we give you the completed code you will learn nothing.

Write code and post it here. Asking for hints on code you have written, then we'll help.
Can you give me some hints?
Post code.

You need to do your own homework, period.

Unless you want to pay for the work. Post in the Jobs section if you want "code for money."
@salem c, The OP is being very specific. He wants us to write all the code for him.
Last edited on
its a common problem with a bajillionty posted solutions on the web. And a good many forums are willing to do it for you on top of that. Its like he went out of his way to land here to get shot down. I don't see a career in problem solving for this kid.
Last edited on
This wasn't his first try at wanting us to write the entire code for him, jonnin.
Topic archived. No new replies allowed.