Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя hexor

Автор hexor, 11 лет назад, По-английски

Can you give me a some trick for xor( exclusive or ) operation?

  • Проголосовать: нравится
  • +17
  • Проголосовать: не нравится

»
11 лет назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится
»
11 лет назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

Given an array of positive integers. Let's assume that every value except one repeat an even number of times. The question is: find the only value that repeats an odd number of times.

For example, if the array is: 6 8 8 6 3 9 3 9 3 the answer is 3, because it repeats an odd number of times.

For the solution, see "Rev. 1" of this comment :)

»
11 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Here you can find some tricks for bit operations http://graphics.stanford.edu/~seander/bithacks.html