Friday, January 24, 2014

SPOJ 7742. Onotole needs your help

Here is the problem statement
http://www.spoj.com/problems/OLOLO/

This task is one of the best tasks in my opinion. At first its not what it looks like but we will need to use only the bitwise operator ^ (XOR). (If you need more information about XOR go here). I am givign you only on good hint. Notice the following , suppose we have 2 number X and Y . If we XOR X and Y we will get some number and when we XOR the new number with the number X we will get Y . Its like Y is being reversed and then reversed again. So if we XOR all the numbers we will get the one which was XORed only once :) .


       DOWNLOAD THE FULL SOURCE CODE

No comments:

Post a Comment