XORIER - Sep18 - Can anyone help me out?

[link text][1]

Above is my solution to War of xor, can anyone tell me what is wrong in my solution ?
[1]: CodeChef: Practical coding for everyone

1 Like

Its integer overflow which is causing you WA. Convert int to long and submit.

still i am getting wa

link text

Look, the multiplication of two integer numbers can give you an answer which is outside the range of int. For example 1000000 * 1000000 . both numbers are in the range of int but the multiplication is 10^12.
which is outside the range of int.
Doing
long a = 10^6 * 10^6; is also wrong. Why? Because first the multiplication operation is performed than the assignment, hence the temporary answer should be stored somewhere but both the operands are int hence answer will we stored as int which is not enough, therefore it gives you wrong value. See this link for example

You can change certain variables to long data type or use 1L while performing some operation(as I did in your code).
Hope it helps:)

Thank you soo much for your help.

1 Like

your code slightly updated gives AC
https://www.codechef.com/viewsolution/20237375