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

×

Explain the code

Can someone please explain me what THIS code is doing. I know that it involves DFS on a tree/graph. It might also involve binary search. I want to know that in init() and lca() functions, why i and j are iterated only till 18?

Problem Link

Contest Link

asked 16 Nov '18, 17:32

meetrockstar's gravatar image

4★meetrockstar
14316
accept rate: 10%

edited 16 Nov '18, 17:41


We want minimum K such that $pow(2,K)>= N$ , here $N = 100000$ .

1.$pow(2,16) = 65536$

2.$pow(2,17) = 131072$

3.$pow(2,18) = 262144$

minimum $K $ satisfying above condition is $17$. Any number $>=17$ will do.

link

answered 17 Nov '18, 01:06

surerr's gravatar image

2★surerr
1
accept rate: 0%

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,404
×1,038
×1,000
×726
×708

question asked: 16 Nov '18, 17:32

question was seen: 108 times

last updated: 17 Nov '18, 01:06