You are not logged in. Please login at www.codechef.com to post your questions!

×

Editorial for XORNEY - PELT2019

Question Code: XORNEY

Prerequisites: Implementation

Problem Setter: tds115

Difficulty: Cakewalk

Explanation: Given two integer l and r, you have to find if xor from l to r is even or odd. Basically, you have to find the number of odd integer between l and r. Since xor of odd 1’s is 1 and xor of even 1’s is 0. You can make 2 cases:- (Let count be the number of odd's) If l is even and r is even-> count=(r-l)/2 Else -> count=(r-l)/2+1 If count is even then ans is even Else odd.
Complexity-O(1) for each query

Author’s solution: https://ideone.com/GUjqC5

asked 11 Jan, 18:01

panik's gravatar image

5★panik
1166
accept rate: 7%

edited 11 Jan, 18:45

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,600
×10
×2
×2

question asked: 11 Jan, 18:01

question was seen: 95 times

last updated: 11 Jan, 18:45