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


CHONQ: time complexity of method

Due to the floor function many values will remain the same. Thus values will for $a_{i}$ will only have to be recomputed after an interval.

$$a_{n} = x. \left\lfloor\dfrac{a_{n}}{x}\right\rfloor+r$$ $$a_{n} = (x-1). \left\lfloor\dfrac{a_{n}}{x}\right\rfloor+\left(r+1.\left\lfloor\dfrac{a_{n}}{x}\right\rfloor\right)$$ $$a_{n} = (x-2). \left\lfloor\dfrac{a_{n}}{x}\right\rfloor+\left(r+2.\left\lfloor\dfrac{a_{n}}{x}\right\rfloor\right)$$ $$a_{n} = (x-3). \left\lfloor\dfrac{a_{n}}{x}\right\rfloor+\left(r+3.\left\lfloor\dfrac{a_{n}}{x}\right\rfloor\right)$$ $$.$$ $$.$$ $$.$$ $$a_{n} = (x-m). \left\lfloor\dfrac{a_{n}}{x}\right\rfloor+\left(r+m.\left\lfloor\dfrac{a_{n}}{x}\right\rfloor\right)$$

This will be valid until the remainder is less than the divisor, thus for the next $ m$ iterations the value dosent have to be updated. $$\therefore x-m\leq r+m.\left\lfloor\dfrac{a_{n}}{x}\right\rfloor $$ $$\therefore \dfrac{x-r}{\left\lfloor\dfrac{a_{n}}{x}\right\rfloor +1}\leq m$$

I used a vector of vectors, where the $i^{th}$ index points to the list of values that are to be updated on the $i^{th}$ iteration. So once u compute m , you can append the index of the person in the $(i+m)^{th}$ position on this array.

link to my solution
can someone please help me with the time complexity of this method?

asked 14 Mar, 20:55

elgawtihcra's gravatar image

accept rate: 0%

edited 14 Mar, 21:00

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 14 Mar, 20:55

question was seen: 75 times

last updated: 14 Mar, 21:00